Carfully look under this line
You have the word private there so your class is private public
[ March 29, 2008: Message edited by: Stuart Smith ]
Oh, and do you need the class to be public to have public methods and variables as well?
As I understand it I am new to Java also.
Encapsulation of fields (class variables) promotes security so they should be private and public methods should be written called setters and getters.
private int somthing;
public setSomthing(int s)
this.something = s;
Originally posted by Stuart Smith:
so your class is private public
Only the constructor, but that's exactly the problem here.
I've managed to get this a lot as well, starting to type a field declaration, then for some reason not finishing it. All that's left is the private, which indeed clashes with the access modifier of the next field, constructor or method.
Originally posted by Muhammad Saifuddin:
you can't declared the class as private but nested class.
This doesn't make sense.
The error in the original poster's code has already been found (a stray word "private"), but some other stuff that's not quite right has been said. Just to put it right...
A top-level class can only be public or package access. You can't have a protected or private top-level class.
A nested class can have any access modifier, including private.
The access level of each constructor and method is separate to that of the class. For instance, even a private class can have a public constructor. The number of times you'd want to do that is small (but there are times).