That's because the variables name and album do not exist in the main procedure, because it's static, which means it cannot access instance-level members. You will need an instance of the Singer class, like this:
public static void main(String[] args) { Singer s = new Singer(); System.out.println("Name of the singer is " + s.name); System.out.println("Album information stored for " + s.album); }
However, unless you declare your name/album members with a public access modifier, the above code will fail to compile. I recommended writing a getter for each member (getName(), getAlbum(), etc), in order to benefit from encapsulation. Like this:
class Singer { private String name; private String album; public Singer() { this.name = "Whitney Houston"; this.album = "Latest Releases"; } public String getName() { return this.name; } public String getAlbum() { return this.album; } public static void main(String[] args) { Singer s = new Singer(); System.out.println("Name of the singer is " + s.getName()); System.out.println("Album information stored for " + s.getAlbum()); } }
Another alternative would be to declare name and album as static, then you can reference them in the way you originally intended.