Static Class Attributes
Lesson 32Author : GOUP
Last Updated : September, 2020
Code
class Song{
public String title;
public String artist;
public static int songCount = 0;
public Song(String title, String artist){
this.title = title;
this.artist = artist;
songCount++;
}
}
public class App{
public static void main(String [] args){
Song mySong = new Song("Holiday", "Green Day");
System.out.println(Song.songCount);
}
}