Java核心技术_笔记3-2

1.
codePointCount()就是准确计算unicode字符的数量,而不是char的数量

2.
StringBuilder sb=new StringBuilder();
sb.append(“hh”);
sb.append(32);
sb显示hh32

3.
输入
Scanner s=new Scanner(System.in);
String a=s.nextLine();//输入字符串

4.
double d = 12345.67890;
System.out.printf(“%8.3f”, d);//8个字符宽度,小数点后3位的浮点数
显示12345.679
这里写图片描述

这里写图片描述

5.
String name=”you”;
String s=String.format(“fuck %s”,name)

6.
PrintWriter out = new PrintWriter(“1.txt”, “UTF-8”);
写入文件,如果没有则创建文件
Scanner in=new Scanner(Paths.get(“1.txt”), “UTF-8”);
读取文件

7.
if( )
{ }
else if()
{}
else
{}

else子句与最近邻的if构成一组

8.
while()
{}

do
{}
while()

9.
for(int i=1;i<9;i++)
{}
i不能再循环之外使用,除非在循环外声明
int i;
for(i=1;i<9;i++)
{}

10.
switch()
{
case 1:
······
break;

case 2:
······
break;

default:
······
break;
}

11.
带标签的break语句,跳出多重循环嵌套语句
label1:
while()
{
while()
{
break label1;
}
}

12.
存储同一类型值的集合
[]表示数组
int[] a=new int[100];

13.
初始化 数组(不是普通变量,依然有new)
数字 0
char 方框
boolen false
对象数组元素 null

14.
for(int element:collection)
{}
遍历collection中每一个element

15.
数组初始化
int[] a={1,2,3};

a=new int[] {4,5,6};

16.
数组用 = 复制的引用
Arrays.copyOf 复制的拷贝
int[] a={4,5,6};
int[] b= Arrays.copyOf(a,a.length);
a[1]=9;
System.out.println(b[1]);
显示b为5,若用=则为9

17.
class Main中
public static void main(String[] args)
运行时在命令行中用
java Main -g world
args[0]为-g
args[1]为world

18.
排序
Arrays.sort(a);

19.
二维数组
int[][]
不能用for(int element:collection)循环
必须用2层

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值