JAVA Format
The java string format() method returns the formatted string by given locale, format and arguments. If you don’t specify the locale in String. format() method, it uses default locale by calling Locale. … The format() method of java language is like sprintf() function in c language and printf() method of java language.
Java String format()
The java string format() method returns the formatted string by given locale, format and arguments.
If you don’t specify the locale in String.format() method, it uses default locale by calling Locale.getDefault() method.
The format() method of java language is like sprintf() function in c language and printf() method of java language.
Parameters
locale : specifies the locale to be applied on the format() method.
format : format of the string.
args : arguments for the format string. It may be zero or more.
formatted string
NullPointerException : if format is null.
IllegalFormatException : if format is illegal or incompatible.
2. public static void main(String args[]){
3. String name=”sonoo”;
4. String sf1=String.format(“name is %s”,name);
5. String sf2=String.format(“value is %f”,32.33434);
6. String sf3=String.format(“value is %32.12f”,32.33434);//returns 12 char fractional part filling with 0
7. System.out.println(sf1);
8. System.out.println(sf2);
9. System.out.println(sf3);
}}
If you like my post please follow me to read my latest post on programming and technology.
Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…
Given an integer A. Compute and return the square root of A. If A is…
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…
A heap is a specialized tree-based data structure that satisfies the heap property. It is…
What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…