Wednesday, 2 March 2016

Java Tutorial : Java String(format method)


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

Click the below Image to Enlarge
Java Tutorial : Java String(format method)
FormatDemo.java
/*
 * public static String format(String format,
 *                                 Object... args)
 * 
 * Returns a formatted string using the specified
 * format string and arguments.
 * 
 * Parameters: 
 * ----------
 * 
 * format - A format string
 * 
 * args - Arguments referenced by the format
 * specifiers in the format string
 */

public class FormatDemo
{

    public static void main(String[] args)
    {
        float floatVar = 12.3f;
        int intVar = 100;
        String stringVar = "Hello,";

        String fs = String.format("The value of the float "
                + "variable is %f, while " + "the value of the "
                + "integer variable is %d, "
                + " and the string is %s", floatVar, intVar,
                stringVar);
        System.out.println(fs);
    }
}
Output
The value of the float variable is 12.300000, while the value of the integer variable is 100,  and the string is Hello,
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/StringDemo_Format_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StringDemo_Format_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/ae1c81370f840697c745970d52d13d8987910b41/BasicJava/StringDemo_Format_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

    Google+ Followers

    Google+ Badge