Search:

Type: Posts; User: Cornix

Search: Search took 0.37 seconds.

  1. Replies
    17
    Views
    1,631

    Re: Assigning random int to strings

    The "==" operator is comparing references or primitive data types.
    The "equals" method compares equality of objects based on the logic defined in the class.

    For example:

    String a = "Test";...
  2. Replies
    17
    Views
    1,631

    Re: Assigning random int to strings

    What Norm means is that you have to do:

    compChoice = "something";
    to assign a value to it.

    The equals method is only supposed to be used for conditional branches in your code. (if, while, etc)
  3. Replies
    17
    Views
    1,631

    Re: Assigning random int to strings

    System.out.println(...) will write to the default Output unless you specify a different output stream for it.
    So by default it will write to the console window. If you are starting from an IDE there...
  4. Replies
    17
    Views
    1,631

    Re: Assigning random int to strings

    1) The for loop looks quite complicated and non-standard.
    You should try to stick with the established standards to make the code easier readable by others (like us).
    Usually a for-loop looks like...
  5. Replies
    17
    Views
    1,631

    Re: Assigning random int to strings

    If you want to have a loop run for a certain number of times prefer a for-loop over a while-loop.

    Example of a for-loop running 17 times:

    int a = 17;
    for (int i = 0; i < a; i++) {
    }
    ...
Results 1 to 5 of 5