标签:java
希望大家给予批评指正,在下感激不尽(未完,待续……)
public class MaxMinFloatDouble { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub float fmax = Float.MAX_VALUE; float fmin = Float.MIN_VALUE; double dmax = Double.MAX_VALUE; double dmin = Double.MIN_VALUE; System.out.println(fmax); System.out.println(fmin); System.out.println(dmax); System.out.println(dmin); /*result: 3.4028235E38 1.4E-45 1.7976931348623157E308 4.9E-324*/ } }
public static void main(String[] args) { int i1 = 0xaaaaaaaa; int i2 = 0x55555555; System.out.println(Integer.toBinaryString(i1)); System.out.println(Integer.toBinaryString(i2)); /** * result * 10101010101010101010101010101010 1010101010101010101010101010101 */ }
/** * @param args */ public static void main(String[] args) { String str1="hello"; String str2="word"; String str3=new String("hello"); testStr(str1, str2); System.out.println("--------------------------"); testStr(str1, str3); } public static void testStr(String s1,String s2){ //boolean b1=s1>s2; //boolean b2=s1<s2; boolean b3=s1==s2; System.out.println(s1+"=="+s2+":\t"+b3); boolean b4=s1.equals(s2); System.out.println(s1+".equals("+s2+"):\t"+b4); boolean b5=s1!=s2; System.out.println(s1+"!="+s2+":\t"+b5); /**result * * hello==word: false hello.equals(word): false hello!=word: true -------------------------- hello==hello: false hello.equals(hello): true hello!=hello: true */ }
public static void main(String[] args) { test(100); } public static void test(int num){ int i=0; while(i<num){ System.out.print(++i); if(i!=100){ System.out.print("、"); } } System.out.println(); int j=0; do{ System.out.print(++j); if(j!=100){ System.out.print("、"); } }while(j<100); System.out.println(); for(int k=0;k<100;){ System.out.print(++k); if(k!=100){ System.out.print("、"); } } }
public static void main(String[] args) { test(); } public static void test(){ int num[] =new int[25]; for(int i=0;i<25;i++){ Random r=new Random(); int n=r.nextInt(); num[i]=n; if(i>0){ compare(num[i-1],num[i]); } } } public static void compare(int n1,int n2){ //System.out.println(n1+"、"+n2+"\n n1>n2:"+(n1>n2)+"\t"+"n1==n2:"+(n1==n2)+"\t"+"n1<n2:"+(n1<n2)); if(n1>n2){ System.out.println(n1+"大于"+n2); }else if(n1<n2){ System.out.println(n1+"小于"+n2); }else { System.out.println(n1+"等于"+n2); } }
标签:java
原文地址:http://blog.csdn.net/ztt_1119/article/details/40589621