Results 1 to 13 of 13

Thread: Error

  1. #1
    ulk27's Avatar
    ulk27 is offline Member
    Join Date
    Apr 2009
    Location
    Turkey
    Posts
    7
    Rep Power
    0

    Thumbs up Error

    Hi Eranda
    I compiled this but I have error
    I am new to this cite
    Can you help me I wonna to much learn Java programing
    I use Netbeans 6.5.1
    Thanks so much



    public class MyQuizTwo {

    public static void main(String[] args) {
    if("String".trim() == "String".trim())
    System.out.println("Yes");
    else
    System.out.println("No");


    }
    }
    Last edited by ulk27; 06-25-2009 at 11:09 PM.

  2. #2
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    post the error message.
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by ulk27 View Post
    Hi Eranda
    I compiled this but I have error
    I am new to this cite
    Can you help me I wonna to much learn Java programing
    I use Netbeans 6.5.1
    Thanks so much

    Few things to clarify here first of all.

    1. Please don't interact with others thread, if your question is not related with it. Simply you can start a new thread, with a well explain title about your question. We have well categorized sub-forums here.

    2. Please read our FAQ page. It's really helpful to you. You can find the FAQ page on top of the page, in main menu, or in my signature.

    3. When you sending your questions next time, try to provide more details you can. Like a code segment in your application, errors if any and so on. The reason is that most people just looking into your code and try to solve it without compile and run the code.

    I'll explain what's going on your code in next post. Good luck :)

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by ulk27 View Post
    Java Code:
    public class MyQuizTwo {
        
        public static void main(String[] args) {
            if("String".trim() == "String".trim())
                System.out.println("Yes");
            else
                System.out.println("No");
    
    
        }
    }
    There is any errors at all, and the answer is Yes. I hope you know that what's going on in the above code, what each line do.

    Can you post your complete error message here to see.

  5. #5
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default equals method

    When working with strings, you should use the .equals() method when comparing strings:
    String (Java Platform SE 6))

    Java Code:
    String myString = "myString";
    String anotherString = "anotherString";
    if (myString.equals(anotherString))
     ....
    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  6. #6
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    @eranga: cool, you can spawn off post now, is that new feature?

    @christ: This came from quiztime, its suppose to be ==.
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by CJSLMAN View Post
    When working with strings, you should use the .equals() method when comparing strings:
    String (Java Platform SE 6))

    Java Code:
    String myString = "myString";
    String anotherString = "anotherString";
    if (myString.equals(anotherString))
     ....
    Luck,
    CJSL

    Yes Chris, we all are advice to work around with this in most of the cases. But I don't know how far our thread starter aware about those things. Anyway we need his comments here.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by angryboy View Post
    @eranga: cool, you can spawn off post now, is that new feature?
    Actually I can do that since I'm a moderator here in Java Forums. ;) Actually it's really nice feature.

  9. #9
    ulk27's Avatar
    ulk27 is offline Member
    Join Date
    Apr 2009
    Location
    Turkey
    Posts
    7
    Rep Power
    0

    Default hi I post the error mesage

    run:
    java.lang.ExceptionInInitializerError
    Caused by: java.lang.RuntimeException: Uncompilable source code - main(java.lang.String[]) is already defined in javaapplication1.Main
    at javaapplication1.Main.<clinit>(Main.java:29)
    Could not find the main class: javaapplication1.Main. Program will exit.
    Exception in thread "main"
    Exception in thread "main" Java Result: 1
    BUILD SUCCESSFUL (total time: 1 second)

  10. #10
    ulk27's Avatar
    ulk27 is offline Member
    Join Date
    Apr 2009
    Location
    Turkey
    Posts
    7
    Rep Power
    0

    Default hi

    İf anybody wonna help me
    thank so much

  11. #11
    ulk27's Avatar
    ulk27 is offline Member
    Join Date
    Apr 2009
    Location
    Turkey
    Posts
    7
    Rep Power
    0

    Default hi

    Sorry for me bad english
    but I progress my english
    every day

  12. #12
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    you are using netbeans?
    That could be an IDE problem, try starting a new project and run the code. Or even better, compile and run it in CMD.
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Code segment you've posted in the your question don't have any problems at all. Is that the complete code you have in that java file? Can you post the complete code to see. May be you've define the main method twice in your Java class.

Similar Threads

  1. Replies: 3
    Last Post: 01-23-2009, 08:53 AM
  2. error 530 error authentication required
    By rgale in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-12-2008, 04:28 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
  •