Page 1 of 2 12 LastLast
Results 1 to 20 of 24
  1. #1
    denisdoherty is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default 'class' or 'interface' expected

    I am having another problem, when i entered in this code
    Java Code:
       private static boolean number(String Number, Interface, theStub){
           try{
               String List = theStub.getnumber();
               StringTokenizer tokens = new StringTokenizer (List);
               while (tokens.hasMoreTokens())
                    if (tokens.nextToken().equalsIgnoreCase(Number))
                        return true;
                    }catch (Exception e) {System.out.println("Error : " + e); } 
            return false;
        }
    It was throwing me back an error class or interface expected but i can not see the problem with the code, does anyone know where i am going wrong.

  2. #2
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    Is this code in a class block?

    eg

    Java Code:
    class Class1 
    {
    
    private static boolean number(String Number, Interface, theStub){
           try{
               String List = theStub.getnumber();
               StringTokenizer tokens = new StringTokenizer (List);
               while (tokens.hasMoreTokens())
                    if (tokens.nextToken().equalsIgnoreCase(Number))
                        return true;
                    }catch (Exception e) {System.out.println("Error : " + e); } 
            return false;
        }
    
    }
    Did this post help you? Please me! :cool:

  3. #3
    denisdoherty is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default

    yes this code is within a class called client

  4. #4
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    I take it 'Interface' & 'theStub' classes actually exsist?
    Did this post help you? Please me! :cool:

  5. #5
    denisdoherty is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default

    yes i have an interface class but on the one that i am working off there is no theStub class in it.

  6. #6
    denisdoherty is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default

    Even when i take out the theStub it says the same thing bout no class or interface expected

  7. #7
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    Well thats your problem.. Its definitely theStub class. I know you have removed the word theStub but dont forget to remove the other reference to it:

    Java Code:
    String List = theStub.getnumber();
    But obviousally without this none of the class will work...

    You need to write theStub class for any of this to work.
    Did this post help you? Please me! :cool:

  8. #8
    denisdoherty is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default

    Yes but how come then the other application that i have works with theStub in and no theStub class do u know?

  9. #9
    denisdoherty is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default

    No that does not work, I am still getting the error class or interface expected on this line private static boolean number(String Number, Interface){

  10. #10
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    Remove all of this:

    Java Code:
          try{
               String List = theStub.getnumber();
               StringTokenizer tokens = new StringTokenizer (List);
               while (tokens.hasMoreTokens())
                    if (tokens.nextToken().equalsIgnoreCase(Number))
                        return true;
                    }catch (Exception e) {System.out.println("Error : " + e); } 
            return false;
    and just run:

    Java Code:
    private static boolean number(String Number, Interface){
    
    }
    What happens?
    Did this post help you? Please me! :cool:

  11. #11
    denisdoherty is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default

    I am getting the same error as before

  12. #12
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    Does your client class have a 'main' method?

    I can't really see what the problem is. Can you post all the code for each class here.
    Did this post help you? Please me! :cool:

  13. #13
    denisdoherty is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default

    Do u want me to post all the code that i have as an attachment and then u will see it all working?

    R what do u want me to post?

  14. #14
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    I just want all the code you are using so I can look at how it is coded. I cant work out why this is not working from what you have posted. Is there a lot of code? If there isnt that much then post it here. Otherwise zip it up.
    Did this post help you? Please me! :cool:

  15. #15
    denisdoherty is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default

    I have attached the file that i am working on, let me know if yoou need any other information
    Attached Files Attached Files

  16. #16
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    Where is theStub class?

    I tried getting all this code to compile but there is all sorts of errors in client.java
    Did this post help you? Please me! :cool:

  17. #17
    denisdoherty is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default

    i said that i dont have a theStub class, with the application that i have, the first error is the class or interface expected.

    I have theStub line commented out so that it is not looking for that class

  18. #18
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    Well not having theStub class is the least of your problems by the looks of it.

    I know you have removed theStub from

    Java Code:
    private static boolean number(String Number, Interface){
    But the rest of that code in the block relies on that class.

    None of this will work:

    Java Code:
           try{
               String List = theStub.getnumber();
               StringTokenizer tokens = new StringTokenizer (List);
               while (tokens.hasMoreTokens())
                    if (tokens.nextToken().equalsIgnoreCase(Number))
                        return true;
                    }catch (Exception e) {System.out.println("Error : " + e); } 
            return false;
    It is being called here:

    Java Code:
    String List = theStub.getnumber();
    Which you already commented out but with this removed, there is no 'List' which is needed for

    Java Code:
    StringTokenizer tokens = new StringTokenizer (List);
    You are going to need theStub for any of that to work.

    Even with that entire code block removed there are still errors as a result in the Client class.
    Last edited by DonCash; 04-22-2008 at 05:58 PM.
    Did this post help you? Please me! :cool:

  19. #19
    denisdoherty is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default

    the one that i am working off is around the same as the one that i have. That does not have a theStub either so what am i suppossed to do then

  20. #20
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    To be honist I have no idea. I removed the number method that has theStub code and there are other errors in the Client class. I commented them out and managed to compile it. This wont work as expected. I can't help you fix it any further.
    Did this post help you? Please me! :cool:

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 04-02-2008, 07:04 AM
  2. class or interface expected -compile err
    By ravi503 in forum Java Servlet
    Replies: 1
    Last Post: 03-26-2008, 11:45 AM
  3. Class inside an Interface
    By $hr!k@nt in forum New To Java
    Replies: 1
    Last Post: 12-21-2007, 10:56 AM
  4. Replies: 9
    Last Post: 08-08-2007, 07:16 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
  •