This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Method help

 
Tyler Hudgens
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having trouble being able to set any values to firstName and lastName. I tried using the normal scanner scan and it wouldnt work. And for some reason i am not able to use Person in public static void main. Shouldnt I be able to type ?


My final code should work with this runner file
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You defined your class Person inside the main() method. While that's possible, it also means that you cannot use class Person anywhere outside the main() method.

Put class Person (lines 16-30 of your first code snippet) inside a separate source file named Person.java instead of inside the main() method.
 
Tyler Hudgens
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright I have done so. But now even when i linked it in BlueJ it keeps giving me the error cannot find symbol - method Person()
SchoolClasses

Person Class

Am i calling it wrong?
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Simply, there is no method Person() that takes zero arguments. There is a default constructor Person() that takes zero arguments -- because you didn't define any constructors.

Do you know the difference between the two? And the difference between calling a method and instantiating an object?

Henry
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And why does your Person class extend SchoolClasses ?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic