Wednesday 9 March 2016

Java Tutorial : Java String(primitive Numbers to Strings-valueOf method)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=W2cFLkeA15c&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java String(primitive Numbers to Strings-valueOf method)
NumberToStringDemo.java
/*
 * Converting Numbers to Strings.
 */
public class NumberToStringDemo
{

    public static void main(String[] args)
    {
        /*
         * Sometimes you need to convert a number to a
         * string because you need to operate on the value
         * in its string form.
         */
        int i = 10;
        String s1 = "" + i;
        System.out.println("s1    = " + s1);

        int j = 199;
        String s2 = String.valueOf(j);
        System.out.println("s2    = " + s2);

        double d = 199.34;
        String s3 = String.valueOf(d);
        System.out.println("s3    = " + s3);

    }
}
Output
s1    = 10
s2    = 199
s3    = 199.34
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/StringDemo_Numbers%20to%20Strings_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StringDemo_Numbers%20to%20Strings_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/764ecf5c6cba932aee2ceef22ba699fc15012e37/BasicJava/StringDemo_Numbers%20to%20Strings_App/?at=master

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment