• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Dharmesh Rathod (Info)

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(1)In one mock exam i found following.
int anar[] = new int[] {1,2,3} ; saying that this line will give compile error , but it is working nicely. As a solution to this error what was said is following.
int anar[3] = new int[] {1,2,3} ; But the solution itself is not working.
(2) In the book of JAVA programming by E. Balaguruswami some model questions are given but so many answers are wrong.
Dharmesh Rathod.
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dharmesh,
The solution given in (1) is definitely wrong. To initialize arrays you can do one of the following:

You cannot do

Hope that helps.
 
The fastest and most reliable components of any system are those that are not there. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic