随笔分类 - Java
摘要:An array of strings String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; An array of integers int[] myNum = {10, 20, 30, 40}; Change an Array Element St
阅读全文
摘要:Break: the "break" stops the loop for (int i = 0; i < 10; i++) { if (i == 1) { break; } System.out.println(i); } // Outputs 0 Continue: The continue s
阅读全文
摘要:int i = 0; do { System.out.println(i); i++; } while (i < 5); // Outputs 0 1 2 3 4 At least it will invoke 1 time the code inside of "do" int i = 0; do
阅读全文
摘要:Instead of writing many if..else statements, you can use the switch statement. int day = 4; switch (day) { // every case will be a posibility of "day"
阅读全文
摘要:Math.max(5, 10); // Outputs 10 Math.min(5, 10); // Outputs 5 Math.sqrt(64); // Outputs 8.0 Math.abs(-4.7); // Outputs 4.7 Math.random(); // returns a
阅读全文
摘要:String Methods: String txt = "Hello World"; System.out.println(txt.toUpperCase()); // Outputs "HELLO WORLD" System.out.println(txt.toLowerCase()); //
阅读全文
摘要:In Java, there are two types of casting: Widening Casting (automatically) - converting a smaller type to a larger type sizebyte -> short -> char -> in
阅读全文
摘要:Primitive types are predefined (already defined) in Java. Non-primitive types are created by the programmer and is not defined by Java (except for Str
阅读全文
摘要:Example Instead of writing: int x = 5; int y = 6; int z = 50; System.out.println(x + y + z); You can simply write: int x = 5, y = 6, z = 50; System.ou
阅读全文
摘要:// students是一个List,stream()表示循环students中的itemsstudents.stream() // filter表示过滤items中符合条件的,student是当前item,studentId是一个parameter .filter(student -> stude
阅读全文

浙公网安备 33010602011771号