
JAVA
JAVA
深蓝蓝蓝蓝蓝
CS博士在读,专注动态3D重建,欢迎交流www
展开
-
upcast和downcast的作用
public class father { public void method( father n){ System.out.println("this is father method use father parameter"); } public void method( child n){ System.out.println("...原创 2019-10-06 22:53:19 · 305 阅读 · 0 评论 -
printf的用法
public class Main { public static void main(String[] args) { // 定义一些变量,用来格式化输出。 double d = 345.678; String s = "你好!"; int i = 1234; // "%"表示进行格式化输出,"%"之...原创 2019-10-06 22:53:15 · 214 阅读 · 0 评论 -
Java中String,int和array参数传递的区别
先定义一个String变量: String a="test"; a中存储的是literal "test"的reference address,literal "test"本身是在string pool(stack-栈)里的。 再定义一个class: Public void class1(String b){ b="test2"; } 当我们调用class1的时候: class1(a); l...原创 2019-10-06 22:53:11 · 560 阅读 · 0 评论 -
find/match pattern in string
// Java code to illustrate find() method import java.util.regex.*; public class GFG { public static void main(String[] args) { // Get the regex to be checked Str...原创 2019-10-06 22:53:06 · 193 阅读 · 0 评论 -
在if中的n++
、、、 class X_5 { public static void main( String args[] ) { int n = 0; while ( true ) { System.out.println("xx"); if ( n++ == 0 ) { System.out.println("n == 0"); } else if ( n++ =...原创 2019-10-06 22:53:02 · 382 阅读 · 0 评论 -
continue、break和return的区别
Java中关键字continue、break和return的区别: continue:跳出本次循环继续下一次循环 break: 跳出循环体,继续执行循环外的函数体 return: 跳出整个函数体,函数体后面的部分不再执行 ...原创 2019-10-06 22:52:57 · 90 阅读 · 0 评论 -
Java中的按位与(&)、按位或(|)、异或(^)等运算符
按位与运算符(&) 参加运算的两个数据,按二进制位进行“与”运算。 运算规则:0&0=0; 0&1=0; 1&0=0; 1&1=1; 即:两位同时为“1”,结果才为“1”,否则为0 例如:3&5 即 0000 0011 &a...转载 2019-10-06 22:52:50 · 3523 阅读 · 0 评论 -
二进制数列遍历法
public class test { public static void main( String[] arguments ) { //十进制数value for ( int value = 0; value < 64; value++ ) { System.out.println( Integer.toBinarySt...原创 2019-10-06 22:52:46 · 904 阅读 · 0 评论 -
java字符串池(string pool)和字符串堆(heap)内存分配
java运行环境有一个字符串池(string pool),由String类维护。执行语句 String str = "abc" 时,首先查看字符串池中是否存在字符串"abc" ,如果存在则直接将"abc"地址赋给str ,如果不存在则先在字符串池中新建一个字符串"abc",然后再将...转载 2019-10-06 22:52:34 · 960 阅读 · 0 评论