标签:小代码
// Q:8 public class HelloWorld { public static void main(String[] args) { int x = 10; System.out.println(" 移位运算有些是快有些慢\n"+( x<<10)); final StringBuffer sb=new StringBuffer("StringBuffer1"); // a.append("StringBuffer2"); //地址所值空间可变 // a=new StringBuffer("StringBuffer2"); //“指针”不可变 /************* C *************** 常量指针 1)const int *p; 2)int const *p; 指针常量的值是指针,这个值因为是常量,所以不能被赋值。 在C/C++中,指针常量这样声明: int a; int *const b = &a; //const放在指针声明操作符的右侧 *******************************/ StringBuffer final_f=new StringBuffer("AB"); System.out.println(" 原内容为:"+final_f); testfinal(final_f); } public static void testfinal(final StringBuffer final_f) { final_f.append("CD");System.out.println(" strcat 内容追加为:"+final_f); } void main1(String[] args) { int x=10; System.out.println("wzzx--------\n"+(~x+1)); System.out.println("wzzx--------\n"+(x>>>1)); //switch (x>10) switch (x%10) { case 0: System.out.println("x case 0");break; case 1: System.out.println("x case 1");break; } byte bb=1;char cc=‘c‘;short ss=10; // long ll=100;string str="string"; switch (bb%10) { case 0: System.out.println("bb case 0");break; case 1: System.out.println("bb case 1");break; } switch (cc) { case ‘a‘: System.out.println("cc case 0");break; case ‘c‘: System.out.println("cc case 1");break; } switch (ss%10) { case 0: System.out.println("ss case 0");break; case 1: System.out.println("ss case 1");break; } short s1=1; s1+=s1+1; System.out.println("s1="+s1); //s1 = s1 + 1; char c1=‘中‘; char c2=‘文‘; char c3=‘汉‘; char c4=‘字‘; System.out.println("中文输出:"+c1+c2+c3+c4); //http://liqipan.iteye.com/blog/1564081 if((c1 >= 0x4e00)&&(c1 <= 0x9fbb)) { System.out.println("是中文"); } } }
标签:小代码
原文地址:http://wzsts.blog.51cto.com/10251779/1773226