Click here to watch in Youtube :
https://www.youtube.com/watch?v=B9T6PDXwXeE&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java format and printf methods |
Java Tutorial : Java format and printf methods |
public class FormatNumericExample { public static void main(String[] args) { System.out.format("%s, %s", "Hello", "world"); System.out.println("\n---------------------------"); float floatVar = 90.8f; int intVar = 100; String stringVar = "Peter"; System.out .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); } }
Hello, world --------------------------- The value of the float variable is 90.800003, while the value of the integer variable is 100, and the string is Peter
public class PrintfNumericExample { public static void main(String[] args) { System.out.printf("%s, %s", "Hello", "world"); System.out.println("\n---------------------------"); float floatVar = 90.8f; int intVar = 100; String stringVar = "Peter"; System.out .printf("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); } }
Hello, world --------------------------- The value of the float variable is 90.800003, while the value of the integer variable is 100, and the string is Peter
https://sites.google.com/site/javaee4321/java/FormatDemo_format_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/FormatDemo_format_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/d0559102086f9677d57877fbba43556aca45fc19/BasicJava/FormatDemo_format_App/?at=master
See also:
No comments:
Post a Comment