Results 1 to 5 of 5

Thread: simple question

  1. #1
    jwl
    jwl is offline Member
    Join Date
    Jul 2012
    Posts
    93
    Rep Power
    0

    Default simple question

    what is the return value of this code?

    int d = 2;
    int k = "ZNE".hashCode() % 3000;
    int l = "THB".hashCode() % 3000;
    for (int x = 0; x <= l; x++)
    d = (d ^ x) % k;
    return d;

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: simple question

    What did it return when you ran it?

  3. #3
    jwl
    jwl is offline Member
    Join Date
    Jul 2012
    Posts
    93
    Rep Power
    0

    Default Re: simple question

    I copied and pasted it in Netbeans:


    package disposable;


    public class Disposable {
    public static int main(String[] args) {

    int d = 2;
    int k = "ZNE".hashCode() % 3000;
    int l = "THB".hashCode() % 3000;
    for (int x = 0; x <= l; x++)
    d = (d ^ x) % k;
    return d;
    }
    }


    and it said there was no main method.

  4. #4
    jwl
    jwl is offline Member
    Join Date
    Jul 2012
    Posts
    93
    Rep Power
    0

    Default Re: simple question

    I'm sorry I mean no main classes.

  5. #5
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: simple question

    The return of the main method should be void. Judging from your code, you should place your calculations into a separate method and call that method from the main method. Or you could just print d instead of returning it if you want to see the result.
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

Similar Threads

  1. Simple Question
    By new2oojava in forum New To Java
    Replies: 1
    Last Post: 09-29-2011, 07:14 AM
  2. Simple question...
    By Onyx in forum New To Java
    Replies: 10
    Last Post: 08-10-2011, 10:44 PM
  3. Simple question
    By Qsc in forum New To Java
    Replies: 6
    Last Post: 03-06-2011, 11:24 PM
  4. Simple Question
    By stackptr89 in forum New To Java
    Replies: 13
    Last Post: 01-29-2011, 05:35 PM
  5. very simple Question
    By arsenal4ever_11 in forum NetBeans
    Replies: 2
    Last Post: 05-27-2010, 08:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •