Static Class Attributes
Lesson 32Author : 🦒
Last Updated : October, 2017
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);
}
}