Java基础语法Hello world

package hello_;

import java.util.Scanner;
import java.util.Random;

public class Main {
/*
* 1格式
* 2输出可以跟C一样不过前缀需要System.out 输入要申请一个类

* 3申请数组 一维数组 int[] arr = new int[100]; for(i=0;i<arr.length++i)
* 4Math.abs()
* 5在输出的时候+只负责连接,若想要数值+需要外加()
* 6多重循环break 可以用标号跳出
here: 
for (int i = 1; i <= 4; i++) { 
a1 = "外层循环第"+i+"层"; 
for (int j = 1; j <= 4; j++) { 
b1 = "内层循环第"+j+"层"; 
if (2 == j & 2 == i) { 
break here; 
}

}
for-Each模式 for(int k:array)//可以用来枚举的东西可以用,string不可
* 7 boolean bool 而且 Java中的布尔类型只有true和false这两种表达状态的量,和C中false默认为0,true默认为1不同
* 8 final const
* 9 Java中的字符类型char 采用的是Unicode的方式 有16位,一个汉字可以用一个char表示
* 10 '/b'回退,在console里才会有??? '/t' tab
* 11 包裹
* boolean Boolean
* char Character
* int Integer
* double Double
* 12 Math
* abs, pow(浮点), round(四舍五入),random(0,1)
* 13 in.next(); 读入一个单词,空格 tab 换行都是阻隔 scanf("%s")
* in.nextLine(); 读入一整行 getline
* 14 字符串
* == 是用来判断string a,b;是否管理同一个东西
* string s = "abc";
* System.out.println(s=="abc");//false
* System.out.println(s.equals("abc"));//true

* string s1 = "abc";
* string s2 = "abd";
* System.out.println(s1.compareTo(s2));//1 (s1 > s2) ? 1 : 0;

* s.charAt(index)// c: s[index]

* string s = "123456abc3"
* s.substring(2)//3456abc
* s.substring(2, 4)//34
* s.indexOf('3');//2
* s.indexOf("345");//2
* s.indexOf('A');//-1 不存在返回-1
* 查找的是第二个3
* int loc = s.indexOf(3);
* s1.indexOf('3', loc+1);

* 常用的操作 (不改变自身, 这些函数返回的是一个新的字符串)
* s.startsWith(ch)
* s.endsWith(ch)
* s.trim()
* s.replace(c1, c2)
* s.toLowerCase()
* s.toUpperCase()
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
System.out.println("Hello World");
}
}

猜你喜欢

转载自www.cnblogs.com/iyigfcjkyggvjkk/p/12402635.html