filmov
tv
Learn Java Tutorial for Beginners, Part 24: StringBuilder and String Formatting

Показать описание
In this video by Quordnet Academy for the series Learn Java Tutorial for Beginners how to use and what is StringBuilder and String Formatting have been discussed.
If you would like to discover even more about java programming tutorial or the java complete course I advise you to check out the playlist :
The java string format() method returns a formatted string using the given locale, specified format string and arguments.We can concatenate the strings using this method and at the same time, we can format the output concatenated string.
Signature:
There are two type of string format() method:
public static String format(Locale loc, String form, Object… args)
and,
public static String format(String form, Object… args)
Parameter:
loc– locale value to be applied on the format() method
form– format of the output string
args– It specifies the number of arguments for the format string.It may be zero or more.
Return:
This method returns a formatted string.
Exception:
NullPointerException -If the format is null.
IllegalFormatException -If the format specified is illegal or there are insufficient arguments.
Example:To show working of format() method
// Java program to demonstrate
// working of format() method
class Gfg1 {
public static void main(String args[])
{
String str = "GeeksforGeeks.";
// Concatenation of two strings
// Output is given upto 8 decimal places
// between "My answer is" and "47.65734000" there are 15 spaces
}
}
Output:
My Company name is GeeksforGeeks.
My answer is 47.65734000
My answer is 47.65734000
// Java program to demonstrate
// concatenation of arguments to the string
// using format() method
class Gfg2 {
public static void main(String args[])
{
String str1 = "GFG";
String str2 = "GeeksforGeeks";
//%1$ represents first argument, %2$ second argument
" is: %1$s, %1$s and %2$s", str1, str2);
}
}
Output:
My Company name is: GFG, GFG and GeeksforGeeks
To never miss an update from or channel hit the subscribe button first and if already subscribe hit the bell icon.
1.Follow us on INSTAGRAM for Interesting posts
2.Follow us on LINKEDIN for interesting content on different aspects
3.Don't forget to like our FACEBOOK to get the most out of it
4.Follow us on twitter to get a mix of all
5.If you want to get us on TUMBLR please then click on the link given below
6.Do join our OFFICIAL Telegram for notes of different things
7.For get job update regularly both private and government do join this telegram channel
If you would like to discover even more about java programming tutorial or the java complete course I advise you to check out the playlist :
The java string format() method returns a formatted string using the given locale, specified format string and arguments.We can concatenate the strings using this method and at the same time, we can format the output concatenated string.
Signature:
There are two type of string format() method:
public static String format(Locale loc, String form, Object… args)
and,
public static String format(String form, Object… args)
Parameter:
loc– locale value to be applied on the format() method
form– format of the output string
args– It specifies the number of arguments for the format string.It may be zero or more.
Return:
This method returns a formatted string.
Exception:
NullPointerException -If the format is null.
IllegalFormatException -If the format specified is illegal or there are insufficient arguments.
Example:To show working of format() method
// Java program to demonstrate
// working of format() method
class Gfg1 {
public static void main(String args[])
{
String str = "GeeksforGeeks.";
// Concatenation of two strings
// Output is given upto 8 decimal places
// between "My answer is" and "47.65734000" there are 15 spaces
}
}
Output:
My Company name is GeeksforGeeks.
My answer is 47.65734000
My answer is 47.65734000
// Java program to demonstrate
// concatenation of arguments to the string
// using format() method
class Gfg2 {
public static void main(String args[])
{
String str1 = "GFG";
String str2 = "GeeksforGeeks";
//%1$ represents first argument, %2$ second argument
" is: %1$s, %1$s and %2$s", str1, str2);
}
}
Output:
My Company name is: GFG, GFG and GeeksforGeeks
To never miss an update from or channel hit the subscribe button first and if already subscribe hit the bell icon.
1.Follow us on INSTAGRAM for Interesting posts
2.Follow us on LINKEDIN for interesting content on different aspects
3.Don't forget to like our FACEBOOK to get the most out of it
4.Follow us on twitter to get a mix of all
5.If you want to get us on TUMBLR please then click on the link given below
6.Do join our OFFICIAL Telegram for notes of different things
7.For get job update regularly both private and government do join this telegram channel
Комментарии