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

  • Java
  • Thread starter Robben
  • Start date
  • #1
166
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:

Answers and Replies

  • #4
Filip Larsen
Gold Member
1,277
209

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

Replies
9
Views
2K
Replies
6
Views
6K
  • Last Post
Replies
1
Views
2K
Replies
3
Views
11K
  • Last Post
Replies
3
Views
6K
Replies
20
Views
30K
Replies
5
Views
1K
Top