087, static initialization of the array object array of Java

01. code is as follows:

Package TIANPAN; 

class Book {
     Private String title;
     Private  Double . price; 

    public Book (String T, Double P) { 
        title = T; 
        . price = P; 
    } 

    // the setter, getters, slightly constructor with no arguments 
    public String getInfo () {
         return "title:" + title + ", price:" + . price; 
    } 
} 

/ ** 
 * Notes document here 
 * 
 * @author Tin Pan micro-channel 382 477 247
  * / 
public  class TestDemo {
     public static  void main (String args []) { 
        Book Books [] = new new Book [] {
                 new new Book ( "the Java", 79.8 ),
                 new new Book ( "the JSP", 69.8 ),
                 new new Book ( "the Android", 89.8)} ;        // open up a three-length array of objects 
        for ( int X = 0; X <books.length; X ++) {         // cycle of the output array of content objects 
            System.out.println (books [x] .getInfo ( )) ; 
        } 
    } 
}

 

02. Results are as follows:

 

 

Knowledge has a price, if you think this article valuable, authors agree to pay, micro-channel two-dimensional code can be any amount of a reward to the author (Micro Signal: 382 477 247) Oh, thank you.

Guess you like

Origin www.cnblogs.com/tianpan2019/p/12325443.html