基础语法学习
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" project-jdk-name="zulu-1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="zulu-1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
2
.idea/modules.xml
generated
2
.idea/modules.xml
generated
@@ -2,9 +2,9 @@
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Hello/Hello.iml" filepath="$PROJECT_DIR$/Hello/Hello.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/JavaSE/JavaSE.iml" filepath="$PROJECT_DIR$/JavaSE/JavaSE.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/java学习.iml" filepath="$PROJECT_DIR$/.idea/java学习.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/基础语法/基础语法.iml" filepath="$PROJECT_DIR$/基础语法/基础语法.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,10 +0,0 @@
|
||||
public class Hello {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("主方法");
|
||||
test("传值");
|
||||
|
||||
}
|
||||
public static void test(String S) {
|
||||
System.out.println(S);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
||||
0
Hello/.idea/.gitignore → 基础语法/.idea/.gitignore
generated
vendored
0
Hello/.idea/.gitignore → 基础语法/.idea/.gitignore
generated
vendored
0
Hello/.idea/code.iml → 基础语法/.idea/code.iml
generated
0
Hello/.idea/code.iml → 基础语法/.idea/code.iml
generated
0
Hello/.idea/misc.xml → 基础语法/.idea/misc.xml
generated
0
Hello/.idea/misc.xml → 基础语法/.idea/misc.xml
generated
124
基础语法/out/production/code/.idea/uiDesigner.xml
generated
Normal file
124
基础语法/out/production/code/.idea/uiDesigner.xml
generated
Normal file
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
24
基础语法/src/src/com/kuang/base/Demo02.java
Normal file
24
基础语法/src/src/com/kuang/base/Demo02.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.kuang.base;
|
||||
|
||||
public class Demo02 {
|
||||
public static void main(String[] args) {
|
||||
// 八大基本数据类型
|
||||
// 整数
|
||||
int num1 = 10;//最常用
|
||||
byte num2 = 20;
|
||||
short num3 = 30;
|
||||
long num4 = 1000;//Long类型要在数字后面加个L
|
||||
|
||||
// 小数:浮点数
|
||||
float num5 = 50.1F;//float后面需要加F
|
||||
double num6 = 3.1415926;
|
||||
|
||||
// 字符类型
|
||||
char name = 'A';
|
||||
// 字符串类型,string不是关键字,类
|
||||
String name1 = "测试";
|
||||
boolean flag = true;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
64
基础语法/src/src/com/kuang/base/Demo03.java
Normal file
64
基础语法/src/src/com/kuang/base/Demo03.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.kuang.base;
|
||||
|
||||
public class Demo03 {
|
||||
public static void main(String[] args) {
|
||||
// 整数扩展: 进制 二进制0b 十进制 八进制0 十六进制0x
|
||||
int i = 10;
|
||||
int i2 = 010;//八进制
|
||||
int i3 = 0x10;//十六进制
|
||||
System.out.println(i);
|
||||
System.out.println(i2);
|
||||
System.out.println(i3);
|
||||
// ================================
|
||||
// 浮点数扩展: 银行业务怎么表示
|
||||
// BigDecimal 数学工具类
|
||||
System.out.println(0.1 + 0.2);//0.30000000000000004
|
||||
System.out.println(0.1f + 0.2f);//0.3
|
||||
// ================================
|
||||
// float 有限 离散 舍入误差 大约 接近但不等于
|
||||
// double
|
||||
// 最好完全避免使用浮点数进行比较
|
||||
float f = 0.1f;
|
||||
double d = 1.0 / 10;
|
||||
System.out.println(f == d);//false
|
||||
|
||||
// ==================================
|
||||
// 字符扩展
|
||||
// ==================================
|
||||
char c1 = 'a';
|
||||
char c2 = '中';
|
||||
System.out.println(c1);
|
||||
System.out.println((int) c1);//强制转换
|
||||
System.out.println(c2);
|
||||
System.out.println((int) c2);//强制转换
|
||||
// 所有的字符本质还是数字
|
||||
// 编码 Unicode 表:97=a 65=A 48=0
|
||||
// U0000 UFFFF
|
||||
// ==================================
|
||||
// 转义字符
|
||||
// ==================================
|
||||
System.out.println("Hello\nWorld");//换行
|
||||
System.out.println("Hello\tWorld");//制表符
|
||||
System.out.println("Helloooo\tWorld");//制表符
|
||||
System.out.println("Hello\rWorld");//回车
|
||||
System.out.println("Hello\bWorld");//退格
|
||||
System.out.println("Hello\"World\"");//双引号
|
||||
System.out.println("Hello\'World\'");//单引号
|
||||
String sa = new String("Hello");
|
||||
String sb = new String("Hello");
|
||||
System.out.println(sa == sb);//false
|
||||
|
||||
String sc = "Hello";
|
||||
String sd = "Hello";
|
||||
System.out.println(sc == sd);//true
|
||||
// ==================================
|
||||
// 布尔值扩展
|
||||
// ==================================
|
||||
boolean flag = true;
|
||||
if (flag) {
|
||||
System.out.println("真");
|
||||
} else {
|
||||
System.out.println("假");
|
||||
}
|
||||
}
|
||||
}
|
||||
26
基础语法/src/src/com/kuang/base/Demo04.java
Normal file
26
基础语法/src/src/com/kuang/base/Demo04.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.kuang.base;
|
||||
|
||||
public class Demo04 {
|
||||
public static void main(String[] args) {
|
||||
int i = 128;
|
||||
byte b = (byte) i;//内存溢出
|
||||
|
||||
// 强制转换(类型)变量名 高->低
|
||||
// 自动转换 低->高
|
||||
System.out.println(i);
|
||||
System.out.println(b);
|
||||
/*
|
||||
注意点:
|
||||
1.不能对布尔值进行转换
|
||||
2.不能把对象类型转换为不相干的类型
|
||||
3.把高容量转换到低容量的时候,强制转换
|
||||
4.转换的时候可能存在内存溢出,或者精度问题!
|
||||
*/
|
||||
System.out.println((int) 23.7);//23
|
||||
char c = 'a';
|
||||
int d = c + 1;
|
||||
System.out.println(d);//98
|
||||
System.out.println((char) d);//b
|
||||
|
||||
}
|
||||
}
|
||||
16
基础语法/src/src/com/kuang/base/Demo06.java
Normal file
16
基础语法/src/src/com/kuang/base/Demo06.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.kuang.base;
|
||||
|
||||
public class Demo06 {
|
||||
public static void main(String[] args) {
|
||||
// 操作比较大的数的时候,注意溢出问题
|
||||
// jdk7新特性,数字之间可以用下划线分割
|
||||
int money = 10_0000_0000;
|
||||
int years = 20;
|
||||
int total = money * years;//-1474836480
|
||||
long total1 = money * years;//默认是int类型,转换之前已经存在问题了
|
||||
long total2 = money * (long) years;//先把一个因子变成long类型,整个表达式发生提升
|
||||
System.out.println(total);//-1474836480
|
||||
long tatal3 = money * ((long) years);
|
||||
System.out.println(tatal3);//20000000000
|
||||
}
|
||||
}
|
||||
10
基础语法/src/src/com/kuang/base/Demo07.java
Normal file
10
基础语法/src/src/com/kuang/base/Demo07.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.kuang.base;
|
||||
|
||||
public class Demo07 {
|
||||
public static void main(String[] args) {
|
||||
int a = 1, b = 2, c = 3, d = 4;
|
||||
String name = "qinjiang";
|
||||
char x = 'X';
|
||||
double pi = 3.14;
|
||||
}
|
||||
}
|
||||
28
基础语法/src/src/com/kuang/base/Demo08.java
Normal file
28
基础语法/src/src/com/kuang/base/Demo08.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.kuang.base;
|
||||
|
||||
public class Demo08 {
|
||||
// 属性:变量
|
||||
// 实例变量:从属于对象;如果不进行初始化,会有一个默认值 0 0.0 null
|
||||
// 布尔值:默认是false
|
||||
// 除了基本类型,其余的默认都是null
|
||||
String name;
|
||||
int age;
|
||||
static double salary = 2500;
|
||||
|
||||
// main方法
|
||||
public static void main(String[] args) {
|
||||
// 局部变量;必须声明和初始化值
|
||||
int i = 10;
|
||||
System.out.println(i);
|
||||
Demo08 demo08 = new Demo08();
|
||||
System.out.println(demo08.age);
|
||||
System.out.println(salary);
|
||||
// 类变量:static
|
||||
|
||||
}
|
||||
|
||||
// 其他方法
|
||||
public void add() {
|
||||
|
||||
}
|
||||
}
|
||||
11
基础语法/src/src/com/kuang/base/Demo09.java
Normal file
11
基础语法/src/src/com/kuang/base/Demo09.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.kuang.base;
|
||||
|
||||
public class Demo09 {
|
||||
// 修饰符不存在先后顺序
|
||||
final static double PI = 3.14;
|
||||
|
||||
public static Number main(String[] args) {
|
||||
System.out.println(PI);
|
||||
return PI;
|
||||
}
|
||||
}
|
||||
17
基础语法/src/src/com/kuang/opertate/Demo01.java
Normal file
17
基础语法/src/src/com/kuang/opertate/Demo01.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.kuang.opertate;
|
||||
|
||||
public class Demo01 {
|
||||
public static void main(String[] args) {
|
||||
// 二元运算符
|
||||
int a = 10;
|
||||
int b = 20;
|
||||
int c = 30;
|
||||
int d = 40;
|
||||
System.out.println(a + b);//30
|
||||
System.out.println(a - b);//-10
|
||||
System.out.println(a * b);//200
|
||||
System.out.println(a / (double) b);//0
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
15
基础语法/src/src/com/kuang/opertate/Demo02.java
Normal file
15
基础语法/src/src/com/kuang/opertate/Demo02.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.kuang.opertate;
|
||||
|
||||
public class Demo02 {
|
||||
public static void main(String[] args) {
|
||||
long a = 123123123123L;
|
||||
int b = 123;
|
||||
short c = 10;
|
||||
byte d = 8;
|
||||
System.out.println(a + b + c + d);
|
||||
|
||||
int e = (int) a;
|
||||
System.out.println(e);
|
||||
|
||||
}
|
||||
}
|
||||
20
基础语法/src/src/com/kuang/opertate/Demo03.java
Normal file
20
基础语法/src/src/com/kuang/opertate/Demo03.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.kuang.opertate;
|
||||
|
||||
public class Demo03 {
|
||||
public static void main(String[] args) {
|
||||
// 关系运算符返回的结果
|
||||
int flag = test(null);
|
||||
System.out.println(flag);
|
||||
}
|
||||
|
||||
public static int test(String[] args) {
|
||||
int a = 10;
|
||||
int b = 20;
|
||||
return a + b;
|
||||
/* System.out.println(a > b);
|
||||
System.out.println(a < b);
|
||||
System.out.println(a == b);
|
||||
System.out.println(a != b);*/
|
||||
|
||||
}
|
||||
}
|
||||
15
基础语法/src/src/com/kuang/opertate/Demo04.java
Normal file
15
基础语法/src/src/com/kuang/opertate/Demo04.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.kuang.opertate;
|
||||
|
||||
public class Demo04 {
|
||||
public static void main(String[] args) {
|
||||
int a = 3;
|
||||
int b = a++;//先赋值后自增
|
||||
int c = ++a;//先自增后赋值
|
||||
System.out.println(a);
|
||||
System.out.println(b);
|
||||
System.out.println(c);
|
||||
// 幂运算 2^3 很多运算 我们会使用一些工具类来操作
|
||||
double pow = Math.pow(2, 3);
|
||||
System.out.println(pow);
|
||||
}
|
||||
}
|
||||
21
基础语法/src/src/com/kuang/opertate/Demo05.java
Normal file
21
基础语法/src/src/com/kuang/opertate/Demo05.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.kuang.opertate;
|
||||
|
||||
//逻辑运算符
|
||||
public class Demo05 {
|
||||
public static void main(String[] args) {
|
||||
// 与 或 非
|
||||
int a = 10;
|
||||
int b = 20;
|
||||
int c = 30;
|
||||
int d = 40;
|
||||
System.out.println(a > b && c > d);//false
|
||||
System.out.println(a > b || c > d);//false
|
||||
System.out.println(!(a > b));//true
|
||||
// 短路运算
|
||||
int e = 5;
|
||||
boolean f = (e < 4) && (e++ < 4);
|
||||
System.out.println(f);//false
|
||||
System.out.println(e);//5
|
||||
|
||||
}
|
||||
}
|
||||
20
基础语法/src/src/com/kuang/opertate/Demo06.java
Normal file
20
基础语法/src/src/com/kuang/opertate/Demo06.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.kuang.opertate;
|
||||
|
||||
public class Demo06 {
|
||||
public static void main(String[] args) {
|
||||
/*
|
||||
* A=0011 1100
|
||||
* B=0000 1101
|
||||
* A&B=0000 1100
|
||||
* A|B=0011 1101
|
||||
* A^B=0011 0001
|
||||
* ~B=1111 0010
|
||||
* 2*8=16 2*2*2*2=16
|
||||
* 效率极高
|
||||
* << *2
|
||||
* >> /2
|
||||
*
|
||||
* */
|
||||
System.out.println(2 << 3);//16
|
||||
}
|
||||
}
|
||||
16
基础语法/src/src/com/kuang/opertate/Demo07.java
Normal file
16
基础语法/src/src/com/kuang/opertate/Demo07.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.kuang.opertate;
|
||||
|
||||
public class Demo07 {
|
||||
public static void main(String[] args) {
|
||||
int a = 10;
|
||||
int b = 20;
|
||||
a += b;//a=a+b
|
||||
a -= b;//a=a-b
|
||||
System.out.println(a);
|
||||
// 字符串连接符
|
||||
System.out.println(a + b);
|
||||
// 字符串连接符
|
||||
System.out.println("" + a + b);
|
||||
System.out.println(a + b + "");
|
||||
}
|
||||
}
|
||||
16
基础语法/src/src/com/kuang/opertate/Demo08.java
Normal file
16
基础语法/src/src/com/kuang/opertate/Demo08.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.kuang.opertate;
|
||||
|
||||
import com.kuang.base.Demo09;
|
||||
|
||||
public class Demo08 {
|
||||
public static void main(String[] args) {
|
||||
// x?y:z
|
||||
// 如果x==true,则结果为y,否则结果为z
|
||||
int score = 80;
|
||||
String type = score < 60 ? "不及格" : "及格";
|
||||
// System.out.println(type);
|
||||
Demo09 demo09 = new Demo09();
|
||||
demo09.main(null);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user