Results 1 to 2 of 2

Thread: Classes and Arrays

  1. #1

    Thread Starter
    Lively Member fundean's Avatar
    Join Date
    Apr 2001
    Posts
    98

    Red face Classes and Arrays

    How does one declare an array of classes in Java and then use methods of the class when calling upon the array?

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Do you mean somthing like this?
    Code:
    public class Q{
         public static void main(String[] args){
           double d = 1.5;
           Z[] z = {new Z()};
           long  l =  z[0].round(d);
          System.out.println(" The value of " + d + " rounded " + " = "  + l);
      
    
        }
    }
    
    class Z{
       public long round(double d){return Math.round(d);}  
     }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width