Click here to watch in Youtube :
https://www.youtube.com/watch?v=gcZsY4HONso&list=UUhwKlOVR041tngjerWxVccw
/* * Converting Numbers to Strings. */ public class NumberToStringDemo { public static void main(String[] args) { /* * Each of the Number subclasses includes a class * method, toString(), that will convert its * primitive type to a string. */ double d = 543.48; String s = Double.toString(d); System.out.println("s = "+s); int dot = s.indexOf('.'); System.out .println(dot + " digits " + "before decimal point."); System.out.println((s.length() - dot - 1) + " digits after decimal point."); int i = 190; String s3 = Integer.toString(i); System.out.println("s3 = "+s3); } }
s = 543.48 3 digits before decimal point. 2 digits after decimal point. s3 = 190
https://sites.google.com/site/javaee4321/java/StringDemo_Numbers%20to%20Strings_toString_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StringDemo_Numbers%20to%20Strings_toString_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/764ecf5c6cba932aee2ceef22ba699fc15012e37/BasicJava/StringDemo_Numbers%20to%20Strings_toString_App/?at=master
See also:
No comments:
Post a Comment