Hi.
It is this theater.
I want to talk about a string format.
OK.
So first we need to create a Java project.
So just click on this file new and then click on Java project.
OK.
And for the project name just type in here a thrain format.
OK.
And then click on finish and we need a main class for our project.
So just click on the RC folder and then click on File New and then click on class.
So for the class name just type in here Main and then click for the package name.
Just type in here com that your name dot product name OK.
A strange format.
OK.
And for the modifiers choose public.
And for the.
And here make sure that we've checked the search box here that says public static void main method.
OK.
And then click Finish.
So as you can see here our main class is now created.
And then I double click on this main that job I have here in order to make this editor area wider.
So now I want to talk about a string format in Java.
OK so what is string formats.
First of all let me point out that sometimes we need to compose strings from valuables like integers.
OK.
And other text string that format is ideal here.
It provides a format language to which we add value of else.
OK so now I'll show you more examples in order to make this concept more meaningful for you to insert
numbers we can use that letter to the format.
OK we use ordinals after the initial per cent symbol starting at 1 and increasing.
This indicates which argument to insert.
OK.
So for the integers we use the format.
OK so now let me just type in here.
Strange that format and as you can see here we need to pass values to this method.
Ok this method accepts arguments.
Ok the first argument is a strain that describes the desired formatting of the output from then on these
arguments can have a multiple number of arguments of any type at runtime these arguments will be converted
to strange and will be printed according to the formatting instructions.
OK so now I want to show you the most basic rule that string formatting follows.
OK.
So as you can see here this is the most basic rule that string formatting follows.
Ok so first of all we need to put the percent sign.
OK so the person sign is a special character denoting that a formatting instruction follows.
So let me repeat again this person sign here is a special character denoting that of formatting an instruction
follows.
And the second one is argument index OK argument index as against Sahir argument index explicitly denoted
the index of the arguments to be formatted.
OK if it is not present arguments will be formatted in the same order as they appear in the arguments
list this argument index explicitly denoted the index of the arguments to be formatted.
OK if it is not present arguments will be formatted in the same order as they appear in the arguments
list the next one is flat.
OK.
As you can see here flag is a special formatting instruction for example.
Plus flag specifies that a numeric value should always be formatted with a sign and the zero flag specifies
that 0 is the Padden character and the next one is Viets as you can see here.
OK.
With the denotes the minimum number of output characters for that object.
OK so now let me repeat again with the nodes the minimum number of output characters for that object.
OK.
And the next one is Dadds precision.
This denotes the precision of floating point numbers in the outputs.
That is basically the number of decimal digits you wish to print on the output but it can be used for
other types to truncate the output with.
OK.
And the next one.
Type R-Ga. type B 8 percent are the only mandatory formatting arguments type simply denotes the type
of the object that will be formatted in the outputs for integers.
That is the four strings that is best for floating point numbers that is F for integers with hex format
that is x.
Ok so now I want to show you some real examples.
And then and then this can actually make sense for you.
OK.
So now I want to actually create.
So now let me actually comment out this line of code here.
In order to let the compiler to run my code.
And now I want to actually create a string object.
So there.
So first I need to refer to the string class as strange and that the name of my object is a string.
Result.
OK.
And then I put in an assignment operator here and then I refer to the name of the string class.
A strange dot format.
And as you can see here here we need to actually specify the formatting instructions.
And our second argument is going to actually accept our real values.
Ok so here we need to actually specify the formatting instruction.
So I need to put in two double quotes here and then inside the double quotes I can actually specify
the formatting instruction for my string of object.
OK.
So here I want to actually typing integer percent.
D city is the type of our string formatting.
So person sign and the type are the only mandatory formatting arguments.
OK.
And then I want to actually specify a new line character by using dislike for the slash character plus.
And.
OK.
And then I press on tab key on my keyboard and then I can actually passing my values for example number
58.
OK.
And that I need to put in a semi-colon at the end of my statement.
OK.
And now I want to output this string result object to the console.
So I just need to type in here or system that out does princeling and then inside the prentices I just
need to refer to the name of the to the name of the string with that object.
And then I need to put in a semicolon at the end of my statement.
And now if I go on my project as you can see it's going out with this value to the console OK.
So as you can see here first of all I specified the formatting instructions for my value as you can
see here.
Integer call 1 percent type.
And this is the newline character OK.
So for example if you want to actually output another value to the console Let's see what happens.
System that out that princeling and then inside the prentices are just put two double codes that in
some text here and then I need to put in a semicolon at the end of my statement.
And if I had on my project now as you can see it's going to actually put this text here.
OK below this value.
OK but if we don't actually put this new line together here and if I don't my project now as you can
see it's going to put this value here.
OK.
So this near-light you can actually put a space between these two values.
Ok so now let me show you another example about floating point numbers.
So first let me actually comment out these lines of code here and now again I want to create a string
object.
So first I need to refer to the String class as strange and the name of the object is.
Strange.
OK.
And then we need to put in an assignment operator here and then we need to refer to this in class strength
that format.
And here first of all we need to specify formatting instructions OK for our object.
We need to put it into double quotes and then inside it calls.
Now I can specify the formatting instructions.
OK.
So a floating or floating point number with Freet decimal digits.
And then I just put in a colon here colon here and then I put a space here and then I can specify the
formatting instruction.
And then I can specify the formatting Kear percent point free
back for Slash and so as you can see here first I put the percent character here as you can see here.
First Vinita putting this person's character.
And then we can specify the argument index flag or the data precision and the type but the person's
character and that height is mandatory for our formatting arguments.
OK.