Results 1 to 4 of 4

Thread: aargghhh...[Resolved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    103

    aargghhh...[Resolved]

    i'm pulling my hair out trying to figure out why a '}' is expected at the end of this line:

    public ProductCatalog() {

    my code is too long to post here... anyone have any general tips/suggestions why the compiler's saying this?
    Last edited by Dilenger4; Jun 27th, 2003 at 09:47 PM.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You're probably missing the final } of the class.

    Or maybe you're trying to declare multiple classes in one file, that's illegal AFAIK.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    103
    import java.util.*;
    import java.io.*;

    public class AAA {

    public AAA() {

    String id;

    }

    }

    that's fine.

    public class AAA {

    public AAA() {

    private String id;

    }

    }

    with the private keyword there, an error appears, that says that the '}' is expected, that the method (or constructor) must end... what???

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Variables inside the constructor cannot have access attributes.

    Class variables are declared outside any functions:
    Code:
    public class AAA {
    
      private String id;
    
      public AAA() {
      }
    
    }
    Note: use [code][/code] tags to post code, it preserves indentation.

    From what source are you learning Java?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width