4 Replies - 316 Views - Last Post: 05 April 2012 - 01:54 PM Rate Topic: -----

#1 crazedmeph  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 94
  • Joined: 19-October 09

Non declared class question

Posted 05 April 2012 - 01:39 PM

How do u create a class to not have to be created first? I've see some classes that u can use the class name and then the function, like Int.parseInt() and it was not
Initialized.
Is This A Good Question/Topic? 0
  • +

Replies To: Non declared class question

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4354
  • View blog
  • Posts: 12,160
  • Joined: 18-April 07

Re: Non declared class question

Posted 05 April 2012 - 01:45 PM

They are declared as static using the "static" keyword. For example, main() that I am sure you have seen before is declared static. why? So that main can be called without first needing to instantiate a class.

Look up the keyword "static" for more information. :)
Was This Post Helpful? 0
  • +
  • -

#3 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: Non declared class question

Posted 05 April 2012 - 01:49 PM

It's probably just your wording, but of course the classes you use in a program have to exist, and your program has to be able to access them or their class files to be able to use them. That's what import statements are for, and if a class is used that is not imported, it is either a member of a class that is imported automatically, or the whole qualified name (beyond the default import) must be used, as in Math.abs(), and most if not all of the methods will be static so that an instance of the Match class does not have to exist in order to use its methods.

You might study classes like Integer, Math, System, etc., in the API to see how they're written in order to answer your question or think of some more.
Was This Post Helpful? 0
  • +
  • -

#4 crazedmeph  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 94
  • Joined: 19-October 09

Re: Non declared class question

Posted 05 April 2012 - 01:52 PM

That's what I thought but I've tried it and it didn't seem to work, but I'll look again. I was pretty sure it was making it static
Was This Post Helpful? 0
  • +
  • -

#5 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: Non declared class question

Posted 05 April 2012 - 01:54 PM

Show your code.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1