记录自己学习的知识(然后自己给自己出题)
接上回题目
1.声明一个变量为a,初始化a的值为3,计算根号下(a+6)的值,要输出喔
public class HelloType {
public static void main(String[] args) {
double a;
a=3;
double x = Math.sqrt(a + 6);
System.out.println(x);
}
}
2.创建一个类,类名叫GoodGoodStudy,输出DayDayUp。
public class GoodGoodStudy {
public static void main(String[] args) {
System.out.println("DayDayUp");
}
}
3.(究极难)运用八种数据类型,输出一句有意思的话,可以复用,不可不用喔
public class heihei {
public static void main(String[] args) {
double a=0.0d; double a1=6.6d; float b=3.3f;
int c=404; short d=9; byte e = 6; long f = 99999999;
char g='w'; char g1='a'; char g2='r'; char g3='n'; char g4='i'; char g5='n'; char g6='g';
boolean h=true; boolean i=false;
System.out.println(a1+" 是否打开页面 ");
System.out.println(f+" "+g+""+g1+""+g2+""+g3+""+g4+""+g5+""+g6+" "+h);
System.out.println(b+" "+e+""+d);
System.out.println(a+" 请下载app进行观看 "+i+" "+c);
}
}
6.6 是否打开页面
99999999 warning true
3.3 69
0.0 请下载app进行观看 false 404
嘿嘿嘿,咱们可真是天才
言归正传,开始今日份的学习喔
羊肉串,鱿鱼串,喔,是字符串
上次咱们学过了char字符类型,这难道是串起来的char? char char char char
真形象呢,咱们学着先
public class StringTest {
public static void main(String[] args) {
//不同于char 这里是""喔
String a = "123真神奇orz #。#";
System.out.println(a);
}
}
喔 猴厉害嘞!
重复着每日相同的生活,重复着相同的事,这就是循环
熟话说的好 编程不需英语好,塑料英语闯天下。
if 中文为 如果
for 中文为 为了
swich 中文为 开关????
if i'm GGS {DDU} else {xxx}
if (这里是条件语句喔比如a>xx,a<xx,a==xx){
这里是满足上述条件后所执行的语句
}else 这是固定写法喔 可以没有喔 {
这里面是不满足条件后所执行的语句
}
public class IfTest {
public static void main(String[] args) {
int a=1;
if (a>1){
System.out.println(a+1);
}else {
System.out.println(a-1);
}
}
}
i for 了 you
for(初始化一个参数;条件判断语句,参数满足条件则循环,不满足就跳出来喔;自增条件 可以++i,也可以i--喔){
只要条件满足就会一直一直一直执行下去喔
}
public class ForTest {
public static void main(String[] args) {
for (int i = 0; i < 2; i++) {
System.out.println("1");
}
}
}
天眼开!三目运算符,各种运算神仙!
boolean ? x : y
??????? 你以为我在乱写?确实 我也以为我在乱写
三目运算!
boolean 是布尔类型 比如 2>1满足这判断,则为true 无需定义boolean喔
x : y 是两个选择,左为真,右为假,小孩子才做选择题,我全都要,嘿嘿
?连接两个语句 ?左边的boolean提供真假,再在?右边进行挑选喔。
public class GodTest {
public static void main(String[] args) {
int a=2;
int b=3;
int c = a>b?a:b;
System.out.println(c);
}
}
运行结果为3
&,|,!
与或非,yyds!
public class GodTest {
public static void main(String[] args) {
int a=1;
int b=2;
boolean c=!(a>b);
System.out.println(c);
}
}
运行结果为 true
public class GodTest {
public static void main(String[] args) {
int a=1;
int b=2;
boolean c= a==1&b==1;
System.out.println(c);
}
}
运行结果为false
public class GodTest {
public static void main(String[] args) {
int a=1;
int b=2;
boolean c= a==1|b==1;
System.out.println(c);
}
}
运行结果为true
咳咳 最基础的java学的差不多了,开始征战方法了喔
今天就不学了,正所谓劳逸结合,大家一起加油学习吧,今日份自出题(伪)
1.长方形,正方形,再来一个三角形(ps。用**喔)
2.救救孩子吧,孩子不会算5的阶乘5!
3.你是男孩还是女孩,男的输出“我是男孩子”,女的输出“我是女孩子”