Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Beginning Java and the fly likes help please quick question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help please quick question" Watch "help please quick question" New topic

help please quick question

Jacob Rich

Joined: Jan 02, 2007
Posts: 27

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.


~"Great is the art of beginning, but greater is the art of ending."~
Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
"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.

SCJP 5.0
Jacob Rich

Joined: Jan 02, 2007
Posts: 27
ah I see, I get what you mean I think... just dont understand what an object class quite is.
Adam Schaible
Ranch Hand

Joined: Oct 04, 2007
Posts: 101
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

Joined: Jan 02, 2007
Posts: 27
very much so, thanks
I agree. Here's the link:
subject: help please quick question