Requirements:m is defined as a property of the class, the constructor must be defined as m assignment, and when m is greater than 99999 , the output error message " the number is too large"and is no longer executed.
Public classT {Private intm; PublicTintm) {Super(); This. m =m; } Public intGetm () {returnm; } Public voidSetm (intm) { This. m =m; } Public voidM () {if(m>99999) {System.out.println ("The number is too large"); } Else{String str=m+ ""; System.out.println ("A total of" +str.length () + "bit"); System.out.println ("Each digit is:"); for(intI=0;i<str.length (); i++) {System.out.print (Str.charat (i)+" "); } System.out.println ("\ n Reverse"); for(intI=str.length () -1;i>=0;i--) {System.out.print (Str.charat (i)); } } } Public Static voidMain (string[] args) {T m=NewT (85412); M.M (); }}
Java Fundamentals Exercise given a positive integer m, the number of bits of m, each digit is printed, and then the numbers are printed in reverse order.