Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why null null?

 
Sandeep Sachan
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I got this question in to my MasterExam i am not getting why the answer is Null and null
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s is always null. What do you expect it to be ?
 
Sandeep Sachan
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am bit confused into this perticular code


please elaborate it in little deep, i ma not getting the part which is there in to main method.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
dhwani mathur
Ranch Hand
Posts: 621
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok!!
public static void main(String [] args)
{
Mineral [] ma = {new Mineral(), new Gem()};

for(Object o : ma)
getWeight((Mineral)o);
}

here Mineral is the Base class,ma is the reference to the class Mineral
you will notice at right side new Mineral,new Gem......now here it is instantiated by writing "new" ...."so ma becomes the object".

Later enhanced for loop is used,where Object o is assigned object ma(actualy value),than getweight method is called.

i hope it helps you to atleast some extent.
 
Bharat Makwana
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sandeep Sachan:
[QB]Hi, I got this question in to my MasterExam i am not getting why the answer is Null and null

Sorry budy,but answer is null null , you have capitalized N in first one

 
Sandeep Sachan
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ranchars,
 
prateek urmaliya
Ranch Hand
Posts: 87
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ma is the reference to the class Mineral

[ June 25, 2007: Message edited by: prateek urmaliya ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic