• Post Reply Bookmark Topic Watch Topic
  • New Topic

question on arrays?  RSS feed

 
Naveen Megharaj
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which one of these are legal and how ?can anybody explain. this question is from "ExamLab for SCJP simulator".
 
Rishita Pallavi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Cannot define dimension expressions when an array initializer is provided

2. Seemingly Wrong

3. Correct Usage

4. It must be an integer array, Rather if you observe, the expression given resolves to a int

5. Seemingly Wrong
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naveen, try putting this in a simple class and compile. Then try interpreting the compiler errors.

For your information, only the third one compiles.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!