Search:

Type: Posts; User: Norm

Search: Search took 0.11 seconds.

  1. Replies
    22
    Views
    782

    Re: Static in a non static

    What does that version of code output to the console?
    Why does the method have a print statement inside of it? What happens when you comment out the print statement that is inside of the method?...
  2. Replies
    22
    Views
    782

    Re: Static in a non static

    Ok so the String returned by the toString method should have the elements of the array separated by a single space.
    To do that write a loop that iterates though the array and concatenates each...
  3. Replies
    22
    Views
    782

    Re: Static in a non static

    You need to decide what String the toString method will return and then work on the code to build that String.
    I've asked for a sample String to show what you want the method to return.
    Without...
  4. Replies
    22
    Views
    782

    Re: Static in a non static

    Please post the exact String that the method should return for this array: int[] arr = { 3, 4, 5, 6, 7 };
    For example: "34567"

    Once we get that we can work on how to build that String.
  5. Replies
    22
    Views
    782

    Re: Static in a non static

    What should the method return? Given this array: int[] arr = { 3, 4, 5, 6, 7 };
    What should be in the String the method returns?
    Post what the desired String would look like for that array.
    ...
  6. Replies
    22
    Views
    782

    Re: Static in a non static

    What happens when the code is compiled? Any errors?
    If no errors, what happens when the code is executed?

    What is the toString method supposed to do? Given the array: int[] arr = { 3, 4, 5, 6,...
  7. Replies
    22
    Views
    782

    Re: Static in a non static

    Sorry, I have no idea what you are asking.

    Can you post the code and a description of what it is supposed to do?
  8. Replies
    22
    Views
    782

    Re: Static in a non static

    The code is calling itself repeatedly until the callstack exceeds the available memory.

    You should NOT give your class the same name (Arrays) as a java SE class: java.util.Arrays.
    Change the name...
  9. Replies
    22
    Views
    782

    Re: Static in a non static

    Please copy the full text of the error message and paste it here. It has important info about the error.

    Those 3 lines of code in post#5 work for me.
  10. Replies
    22
    Views
    782

    Re: Static in a non static

    To call a non-static method you need a reference to an instance of the class.


    System.out.println(toString()); // calls default toString method

    System.out.println(toString(Array)); // calls...
  11. Replies
    22
    Views
    782

    Re: Static in a non static

    Please explain. If there are error messages, copy the full text and paste it here.


    How are you calling the method? Where is the code that passes it an int array?
Results 1 to 11 of 11