Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: I get an error

  1. #1
    Junior Member
    Join Date
    Aug 2013
    Location
    Left coast - US
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default I get an error

    //This is my first java assignment
    //create an employee class with the following attributes: name, age, department

    //Here is what I wrote...
    //I get an error at line 5


    1 public class employee {
    2	
    3	String name[] = {};
    4	int age[] = {};
    5	var dept[] = {};
    6
    7
    8 }
    Last edited by jps; August 13th, 2013 at 12:36 PM. Reason: code tags


  2. #2
    Member
    Join Date
    Jul 2013
    Posts
    219
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default Re: I get an error

    Hello.
    Did you read what the error says?
    If yes can you guess what could be the reason? You clearly said its at line 5.


    Syed.

  3. The Following User Says Thank You to syedbhai For This Useful Post:

    thenick (August 13th, 2013)

  4. #3
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: I get an error

    Quote Originally Posted by thenick View Post
    create an employee class with the following attributes: name, age, department
    The instructions may not be specifically clear, but with a look at the bigger picture, I would expect an instance of "Employee" to represent a single individual employee. I would also expect this employee to have only one name and only one age, though it may be possible for the employee to work in more than one department. (By convention the class name Employee should begin with E rather than e)

    Also please use code tags when posting code, you can find instructions on the Announcements page if you need help.

    On to the error: Always include the full text of any error message with your code and question. Error messages are filled with useful information that is helpful in finding the cause of the problem,
    (usually, but that is another topic).

  5. #4
    Member
    Join Date
    Jul 2013
    Location
    Franklin, TN
    Posts
    47
    Thanks
    3
    Thanked 4 Times in 4 Posts

    Default Re: I get an error

    I would check out some basic tutorials on how to declare variables, and which types hold what kind of values.

    Declaring Member Variables (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    Post your progress and we can assist.

  6. #5
    Member
    Join Date
    Jul 2013
    Posts
    219
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default Re: I get an error

    Alex,
    The error is clearly evident. Maybe you copied that code from some other language.
    There is no predefined "var" datatype in java that you have used.

    Syed.

Similar Threads

  1. Please! Help me to this error "ERROR CANNOT FIND SYMBOL"
    By mharck in forum Object Oriented Programming
    Replies: 8
    Last Post: July 3rd, 2012, 10:20 AM