fork download
  1. class Account{
  2. int a;
  3. int b;
  4. public void setData(int c,int d){
  5. a=c;
  6. b=d;
  7. }
  8. public void showData()throws Exception{
  9. System.out.println("Value of a ="+a);
  10. System.out.println("Value of b ="+b);
  11. }
  12. }
  13.  
  14. class ArrayOfObjects{
  15. public static void main(String args[]) throws Exception{
  16. Account[] obj = new Account[4] ;
  17. for (int i=0;i<Account.length;i++)
  18. obj[i] = new Account();
  19. obj[0].setData(1,2);
  20. obj[1].setData(3,4);
  21. System.out.println("For Array Element 0");
  22. obj[0].showData();
  23. System.out.println("For Array Element 1");
  24. obj[1].showData();
  25. }
  26. }
  27.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:17: cannot find symbol
symbol  : variable length
location: class Account
     for (int i=0;i<Account.length;i++) 
                           ^
1 error
stdout
Standard output is empty