Page 2 of 2 FirstFirst 12
Results 21 to 35 of 35
  1. #21
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Chewart View Post
    ive ammended it but styill getting errors another 2 =( im not giving up on this program i know with some guidence icould do this.. heres where my errors after puttin a { on the programs are ahppenin
    Java Code:
       private DirectoryTest findEntry(String firstName, String lastName)
        
          for (DirectoryTest entry : entries)
          {
            if (entry.getFirstName().equalsIgnoreCase(firstName);
              && entry.getLastName().equalsIgnoreCase(lastName));
            {
              return entry;
            }
          }  
      
    }
    Java Code:
      if (entry.getFirstName().equalsIgnoreCase(firstName);
    ) expected apparently and

    Java Code:
    && entry.getLastName().equalsIgnoreCase(lastName));
    "&&" illegal start of expression
    Don't put semicolons all over the place and I still can't see a left curly bracket at the start of that method; the corrected snippet:

    Java Code:
       private DirectoryTest findEntry(String firstName, String lastName) {
        
          for (DirectoryTest entry : entries)
          {
            if (entry.getFirstName().equalsIgnoreCase(firstName)
              && entry.getLastName().equalsIgnoreCase(lastName))
            {
              return entry;
            }
          }  
      
    }
    kind regards,

    Jos

  2. #22
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    hey Jos many thanks for that i only have one yes one lol error now, line 50 which is the very end of my program is asking me to } expected. i did ammend it but it then gives me 13 errors i cant win dude lol i like java but this is frustrating the hell out of me lol

  3. #23
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Chewart View Post
    hey Jos many thanks for that i only have one yes one lol error now, line 50 which is the very end of my program is asking me to } expected. i did ammend it but it then gives me 13 errors i cant win dude lol i like java but this is frustrating the hell out of me lol
    Those are just simple syntax errors; count your curly braces: they all should match and pair. When programming you have to be painstakingly exact; no sloppy text is allowed by the compiler; that's the way they are and that's the way they have to be.

    kind regards,

    Jos

    ps. I'm not psychic during the weekends so I don't know what you have typed at line 50.

  4. #24
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    hahaha!! good comment jos lol sorry line 50 was the very end of my prgram i have ammended it but now im getting 13 errors =( so frustratin. dont suppose you could compile just to check dude? not asking you to do it for me but would apreciate your input cos u know what ur doin

  5. #25
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Chewart View Post
    hahaha!! good comment jos lol sorry line 50 was the very end of my prgram i have ammended it but now im getting 13 errors =( so frustratin. dont suppose you could compile just to check dude? not asking you to do it for me but would apreciate your input cos u know what ur doin
    Fifty lines of code isn't that much; go ahead, post it here so we all can see what's happening.

    kind regards,

    Jos

  6. #26
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    Java Code:
     import java.util.ArrayList;
    import java.util.List;
    
    public class Directory
    {
        Foo myFoo = new Foo();
        
        private ArrayList<Foo>  fooList = new ArrayList<Foo>();
    
        public void add(DirectoryTest entry)
        {
          entries.add(entry);
        }
        
        public ArrayList<DirectoryTest> getEntries()
        {
          return entries;
        }
    
        public String findNumber(String firstName, String lastName)
        {
          DirectoryTest entry = findEntry(firstName, lastName);
    
          return entry == null ? null : entry.getNumber();
        }
    
        public void updateNumber(String firstName, String lastName, String number)
        {
          DirectoryTest entry = findEntry(firstName, lastName);
    
          if (entry == null)
          {
            throw new IllegalArgumentException("The Entry is not found");
          }
    
          entry.setNumber(number);
        }
       
       private DirectoryTest findEntry(String firstName, String lastName) 
       {
        
          for (DirectoryTest entry : entries)
          {
            if (entry.getFirstName().equalsIgnoreCase(firstName)
              && entry.getLastName().equalsIgnoreCase(lastName))
            {
              return entry;
            }
          }  
    	}
    }
    much appreciated Jos

  7. #27
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Perhaps you're getting just a bit too literal in your cut and pasting of code from the forum. My Foo example was just that, an example. It wasn't code that you can add to your program that will magically work. Get rid of it.

  8. #28
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    Java Code:
    import java.util.ArrayList;
    import java.util.List;
    
    public class Directory
    {
        
        
        private ArrayList<String>  StringList = new ArrayList<String>();
    
        public void add(DirectoryTest entry)
        {
          entries.add(entry);
        }
        
        public ArrayList<String> getEntries()
        {
          return entries;
        }
    
        public String findNumber(String firstName, String lastName)
        {
          DirectoryTest entry = findEntry(firstName, lastName);
    
          return entry == null ? null : entry.getNumber();
        }
    
        public void updateNumber(String firstName, String lastName, String number)
        {
          DirectoryTest entry = findEntry(firstName, lastName);
    
          if (entry == null)
          {
            throw new IllegalArgumentException("The Entry is not found");
          }
    
          entry.setNumber(number);
        }
       
       private DirectoryTest findEntry(String firstName, String lastName) 
       {
        
          for (DirectoryTest entry : entries)
          {
            if (entry.getFirstName().equalsIgnoreCase(firstName)
              && entry.getLastName().equalsIgnoreCase(lastName))
            {
              return entry;
            }
          }  
    	}
    }
    that better? could you point in the right direction. im new to java and a lil help sometimes wouldnt go a miss

  9. #29
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default

    Where is that 'entries' thing? You're using it all over the place, but where is it?

    kind regards,

    Jos

  10. #30
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    ahhh i see where and how could i declare it?

  11. #31
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    Java Code:
    C:\javalab\lab10>javac Directory.java
    Directory.java:10: cannot find symbol
    symbol  : class DirectoryTest
    location: class Directory
        public void add(DirectoryTest entry)
                        ^
    Directory.java:39: cannot find symbol
    symbol  : class DirectoryTest
    location: class Directory
       private DirectoryTest findEntry(String firstName, String lastName)
               ^
    Directory.java:17: incompatible types
    found   : java.lang.String
    required: java.util.ArrayList<java.lang.String>
          return entries;
                 ^
    Directory.java:22: cannot find symbol
    symbol  : class DirectoryTest
    location: class Directory
          DirectoryTest entry = findEntry(firstName, lastName);
          ^
    Directory.java:29: cannot find symbol
    symbol  : class DirectoryTest
    location: class Directory
          DirectoryTest entry = findEntry(firstName, lastName);
          ^
    Directory.java:42: cannot find symbol
    symbol  : class DirectoryTest
    location: class Directory
          for (DirectoryTest entry : entries)
               ^
    Directory.java:42: foreach not applicable to expression type
          for (DirectoryTest entry : entries)
                                     ^
    7 errors
    
    C:\javalab\lab10>javac Directory.java
    Directory.java:9: cannot find symbol
    symbol  : class DirectoryTest
    location: class Directory
        public void add(DirectoryTest entry)
                        ^
    Directory.java:38: cannot find symbol
    symbol  : class DirectoryTest
    location: class Directory
       private DirectoryTest findEntry(String firstName, String lastName)
               ^
    Directory.java:11: cannot find symbol
    symbol  : variable entries
    location: class Directory
          entries.add(entry);
          ^
    Directory.java:16: cannot find symbol
    symbol  : variable entries
    location: class Directory
          return entries;
                 ^
    Directory.java:21: cannot find symbol
    symbol  : class DirectoryTest
    location: class Directory
          DirectoryTest entry = findEntry(firstName, lastName);
          ^
    Directory.java:28: cannot find symbol
    symbol  : class DirectoryTest
    location: class Directory
          DirectoryTest entry = findEntry(firstName, lastName);
          ^
    Directory.java:41: cannot find symbol
    symbol  : class DirectoryTest
    location: class Directory
          for (DirectoryTest entry : entries)
               ^
    Directory.java:41: cannot find symbol
    symbol  : variable entries
    location: class Directory
          for (DirectoryTest entry : entries)
                                     ^
    8 errors
    these are the errors im getting plz plz plz can u help lol

  12. #32
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  13. #33
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

    Default

    so should i create a directorytest program? how could i get round it without creating a new program.could you give me something to go on. i just cnt see it ive bin lukin at this screen all day without any joy

  14. #34
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by chewart View Post
    so should i create a directorytest program?
    as i've been telling you all along!

    Good bye and good luck.

  15. #35
    Chewart is offline Member
    Join Date
    Nov 2009
    Posts
    75
    Rep Power
    0

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Error Message????
    By Cubba27 in forum New To Java
    Replies: 11
    Last Post: 11-21-2009, 03:46 PM
  2. Error Message in JBuilder
    By RavenNevarmore in forum New To Java
    Replies: 4
    Last Post: 10-08-2008, 07:53 AM
  3. strange Error message
    By little_polarbear in forum New To Java
    Replies: 4
    Last Post: 08-26-2008, 12:45 AM
  4. java error message
    By baileyr in forum New To Java
    Replies: 2
    Last Post: 01-23-2008, 04:47 AM
  5. error message on jsp
    By sandor in forum Web Frameworks
    Replies: 1
    Last Post: 04-11-2007, 03:10 AM

Posting Permissions

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