Search:

Type: Posts; User: tyneframe

Search: Search took 0.24 seconds.

  1. Replies
    1
    Views
    222

    problems with my toString method

    Here is my constructor that the toString method pulls from:

    public Actor(String sName, int nStrength, int nSpeed, int nHealthPoints){
    this.sName = sName;
    this.nStrength = nStrength;...
  2. Re: Help with error on second run through array

    Alright, thanks again. I should be able to figure it out at this point.

    --- Update ---

    I solved it! Who knew a ; could cause so much chaos, haha. I'll definitely remember all these...
  3. Re: Help with error on second run through array

    It's almost there. The NPE error at line 108 is gone. I can enter as much info as I want. Now I've just got to deal with the NPE error at line 112 where the user chooses to view the data that has...
  4. Re: Help with error on second run through array

    So, if I move my employeeData[numEmployee] = new Employee(); object down into the loop, that should create a new object each time the user chooses 1.

    Something like this:
    ...
  5. Re: Help with error on second run through array

    Okay this is slowly starting to make sense, but how do I fix my NPE problem without putting data into all 100 slots? 100 is just the max number of slots the user has to work with, but they don't have...
  6. Re: Help with error on second run through array

    Wow, I'm having a hard time accessing the forums right now. Anyway...

    Okay, tried that and I got 'Employee@3c939d40' for the first entry and then I got null values. I'm assuming 99 null values...
  7. Re: Help with error on second run through array

    Ah sorry, misunderstood what you wrote. That I know how to do.
    so, to call the elements in the array I should write:
    System.out.println(employeeData[numEmployee]); ?

    But all I get is null as a...
  8. Re: Help with error on second run through array

    Sorry, not sure I understand what you mean. How do I add a call to the println?
  9. Re: Help with error on second run through array

    If I'm not mistaken, I'm putting objects into my array with line 108...am I not? But if that's the case, I am getting the NPE because the entry is not being put into the array properly. Is that what...
  10. Re: Help with error on second run through array

    That's my problem. I don't know what is null at line 108. Nothing is null the first time I run through, so I don't understand why something is null the second time. Is there a way to find out what is...
  11. Help with error on second run through array

    I'm having some issues with entering data into my array. The first run through the loop has no issues...that I can see, but once I have entered the first batch of information I start getting Null...
  12. Replies
    4
    Views
    353

    Re: A little help with looping my array

    Here's the updated code, and the error message is:
    "Exception in thread "main" java.lang.NullPointerException at Employee.main(Employee.java:109)"



    public static void main(String[] args) {
    ...
  13. Replies
    4
    Views
    353

    Re: A little help with looping my array

    Hey, thanks. That did the trick... but also brought up a new problem it seems. After I select 1 for the first time and enter some information it loops me back to the menu and asks me to select again....
  14. Replies
    4
    Views
    353

    A little help with looping my array

    Nearing the end of this assignment and am having a little trouble figuring out a way to get my loop to return to the proper place each time it repeats. Here's the section of code I'm working on:

    ...
  15. Replies
    7
    Views
    445

    Re: Simple loop problem

    Thank you so much for the help! It works perfectly now. Can't believe I forgot the == thing.
    Thanks again.
  16. Replies
    7
    Views
    445

    Re: Simple loop problem

    Hm, I'm still not sure what I'm doing wrong. I've tried entering the boolean and setting the result based on the numberEntered just like you said, but I keep getting an error that says "cannot make a...
  17. Replies
    7
    Views
    445

    Re: Simple loop problem

    Sorry, my mistake. It is supposed to keep repeating until the user enters 13. How do I go about setting a value to finished?
  18. Replies
    7
    Views
    445

    Simple loop problem

    At least I think the solution to my problem will involve a loop. I'm new to java, so I'm sorry if I'm on the wrong board.
    Basically, my code asks the user to enter a number from 1 - 12 and it then...
  19. Replies
    4
    Views
    321

    Re: User entry needs to be exactly 5 digits

    Thank you very much for the help and links. I'll check them out.
  20. Replies
    4
    Views
    321

    Re: User entry needs to be exactly 5 digits

    Repeating the main method seemed like the simplest thing to re-run the code and allow the user to re-enter a number, if their first try was invalid. I am new to this...only a couple of weeks into the...
  21. Replies
    4
    Views
    321

    User entry needs to be exactly 5 digits

    Just starting out in Java and need a little help.
    I'm writing a simple code where the user is asked to enter a 5 digit number, otherwise they get a 'please try again' message. I've figured out most...
Results 1 to 21 of 21