• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help please quick question

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ah I see, I get what you mean I think... just dont understand what an object class quite is.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
very much so, thanks
reply
    Bookmark Topic Watch Topic
  • New Topic