public class Usingattribute {static String stra = "String-a"; Static String StrB; static String strc = "String-c"; Static String StrD; static {printstatic ("before Static"); StrB = "Sring-b"; Printstatic ("after Static"); public static void Printstatic (String title) {System.out.println ("------" +title+ "-----"); System.out.println ("stra=\" "+stra+" \ ""); System.out.println ("strb=\" "+strb+" \ ""); }public static void Main (string[] args) {//TODO auto-generated Method Stub System.out.println (); SYSTEM.OUT.PRINTLN ("----Create Usingattribute object---"); System.out.println (); New Usingattribute ();} Public Usingattribute () {print ("before constructor"); Strd= "string-d"; Print ("after constructor"); public static void print (String title) {System.out.println ("------" +title+ "-----"); System.out.println ("stra=\" "+stra+" \ ""); System.out.println ("Strb=\" "+strb+ "\" "); System.out.println ("strc=\" "+strc+" \ ""); System.out.println ("strd=\" "+strd+" \ ""); }}
Use of the attribute group for the Java summary class