Java programming ideology fourth edition Chapter 3 personal exercises, programming ideology Fourth Edition

Source: Internet
Author: User

Java programming ideology fourth edition Chapter 3 personal exercises, programming ideology Fourth Edition

I hope you will be grateful for your criticism ......)
Chapter 3 exercise 9 (1) show the maximum and minimum numbers represented by float and double indexes respectively


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*/      }   }

Exercise (10) Compile a program with two constant values, one with alternating binary bits 1 and 0, with the lowest valid bits 0, the other also has alternate binary bits 1 and 0, but the minimum valid bits is 1 (Tip: Use a hexadecimal constant to represent the simplest method ). take two values, use the bitwise operator to combine them in all possible ways, and then use Integer. toBinaryString () display
    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     * 101010101010101010101010101010101010101010101010101010101010101     */    }  

Exercise 14 (3) Compile a method to receive two string parameters, compare the two strings with the comparison of various boolean values, and print the results. Do = and! = At the same time, use equals () for testing. Use several different string objects in main () to call this method.
         /** * @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:falsehello.equals(word):falsehello!=word:true--------------------------hello==hello:falsehello.equals(hello):truehello!=hello:true */}





Who has the answer to the fourth edition of java programming ideas?

No one answered the question. Join the QQ group about JAVA or join the group about this book directly. They have answers. I am also a fan. I suggest using this!

Which of the following has bought Thinking in Java Chinese JAVA programming ideology version 4? Exercise 3 on page 1 find out what is the code break with ATYPENAME?

The answer electronic version and code have been sent. Please check.

// TIJ4 Chapter Object, Exericise 3, page 90
// Object/ATNTest. java
// Find the code fragments involving ATypeName and turn them into a program
// That compiles and runs.
Your answer
Public class ATNTest {
Public static void main (String [] args ){
Class ATypeName {
Int I;
Double d;
Boolean B;
Void show (){
System. out. println (I );
System. out. println (d );
System. out. println (B );
}
}
ATypeName a = new ATypeName ();
A. I = 3;
A. d = 2.71828;
A. B = false;
A. show ();
}
}
Remember to give the score. If you have any questions, please ask.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.