2013年6月27日

JAVA迭代:foreach语法测试,简约实用

摘要: /**** @author caryt**/public class test {/*** @param args*/public static void main(String[] args) {// TODO Auto-generated method stub//迭代 foreach语法String[] Str={"test1","test2","test3","test4","test5","test6","test7","test8&q 阅读全文

posted @ 2013-06-27 11:57 caryt 阅读(140) 评论(0) 推荐(0)

JAVA舍入,截尾测试

摘要: /**** @author caryt**/public class test {/*** @param args*/public static void main(String[] args) {// TODO Auto-generated method stub//结尾:System.out.println("舍入截尾测试:"+(int)0.6f+" : "+(int)0.7);//舍入需要round()方法System.out.println("舍入:"+Math.round(0.6f)+" 舍入:"+Mat 阅读全文

posted @ 2013-06-27 11:35 caryt 阅读(170) 评论(0) 推荐(0)

JAVA随机数Random

摘要: /**** @author caryt**/public class test {/*** @param args*/static int x[]=new int[15];public static void main(String[] args) {// TODO Auto-generated method stubRandom random=new Random();int x = 0,y = -1;do {x=random.nextInt(10);//0~10;y=random.nextInt(10);System.out.println("x: "+x+" 阅读全文

posted @ 2013-06-27 11:15 caryt 阅读(134) 评论(0) 推荐(0)

JAVA三元运算

摘要: /**** @author caryt**/public class test { static String test2(){ int i=9; return i<10? "yes":"no"; }/*** @param args*/public static void main(String[] args) {// TODO Auto-generated method stubSystem.out.println(test.test2());}}out: yes 阅读全文

posted @ 2013-06-27 11:13 caryt 阅读(98) 评论(0) 推荐(0)

JAVA逻辑操作符测试

摘要: /**** @author caryt**/public class test { /*** @param args*/public static void main(String[] args) {// TODO Auto-generated method stubint a=2;int b=3;System.out.println("a>b:"+(a>b));System.out.println("a=b:"+(a>=b));System.out.println("ab:falsea=b:falsea<=b:true 阅读全文

posted @ 2013-06-27 10:20 caryt 阅读(120) 评论(0) 推荐(0)

JAVA对象的比较测试

摘要: /**** @author caryt**/public class test { /*** @param args*/static int x[]=new int[15];public static void main(String[] args) {// TODO Auto-generated method stubString t1=new String("caryt");String t2=new String("caryt");System.out.println(t1==t2);//比较的是对象的引用System.out.println(t1 阅读全文

posted @ 2013-06-27 10:09 caryt 阅读(98) 评论(0) 推荐(0)

JAVA类,别名问题

摘要: /* * * @author caryt * */class test1{String thh="caryt1";}/**** @author caryt**/public class test { static void test2(test1 t3){ t3.thh="caryt3"; }/*** @param args*/public static void main(String[] args) {// TODO Auto-generated method stubtest1 t1=new test1();test1 t2=new test1() 阅读全文

posted @ 2013-06-27 09:59 caryt 阅读(140) 评论(0) 推荐(0)

Java基础,自减自增"--","++"

摘要: 简单示例:int i=1;int a,b,c,d;b=i++;c=++i;a=i--;d=--i;System.out.println("b:"+b+" c:"+c+" a:"+a+" d:"+d); out:b:1 c:3 a:3 d:1 阅读全文

posted @ 2013-06-27 09:53 caryt 阅读(105) 评论(0) 推荐(0)

导航