Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help please quick question

 
Jacob Rich
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

in the above line of code Math.random() is a method right? I'm trying to learn and i'm just not sure about which are variables, objects, and methods in code, havent had much experience yet.

Thanks.
 
Kelvin Chenhao Lim
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Math.random()" is a call to the static method "random" of the "Math" class. Static methods can be invoked directly with the class name, without first instantiating an object instance of the class. Normal (non-static) methods can only be invoked on object instances.
 
Jacob Rich
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ah I see, I get what you mean I think... just dont understand what an object class quite is.
 
Adam Schaible
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Jacob,

Whenever you create a new file and type

you're creating a class.

In your code, when you do something like:


you're creating an object. The common example is that a class is an object's blueprint. In the class, you define what attributes the object may have, what behavior it may have, etc.

A class and an object are different states of the same thing - not unlike water and ice.

Does that help?
 
Jacob Rich
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
very much so, thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic