How do I create an instance of a class in a method using Java?

  • Context: Java 
  • Thread starter Thread starter Robben
  • Start date Start date
  • Tags Tags
    Class Java Method
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
Robben
Messages
166
Reaction score
2

Homework Statement



How do I create an instance of a class in a method?

Homework Equations



None

The Attempt at a Solution



I am a bit rusty whenever I think of instances. I always think of main method and objects when I see instance which gets me confused on what to do with the following example:

I have a abstract class, School, and inside School I have some methods that must preform some action on an instance. For example, there is a move() method that must move the instance of School. Another method named, personOld(), which returns whether or not an instance of School surpassed some determined age.
How do I create this instance?
 
Last edited:
Physics news on Phys.org