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?
Printable View
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?
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.
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???
Variables inside the constructor cannot have access attributes.
Class variables are declared outside any functions:
Note: use [code][/code] tags to post code, it preserves indentation.Code:public class AAA {
private String id;
public AAA() {
}
}
From what source are you learning Java?