jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Method help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Method help" Watch "Method help" New topic

Method help

Tyler Hudgens

Joined: Dec 09, 2013
Posts: 7
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

Joined: Aug 16, 2005
Posts: 15094

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Tyler Hudgens

Joined: Dec 09, 2013
Posts: 7
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()

Person Class

Am i calling it wrong?
Henry Wong

Joined: Sep 28, 2004
Posts: 20535

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?


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 679
And why does your Person class extend SchoolClasses ?
I agree. Here's the link: http://aspose.com/file-tools
subject: Method help
It's not a secret anymore!