Netbeans tutorial

hi everyone so we have learnt a few things so far let's just go through them so so far we have learned about input and output through text field so we had used for input we had used method get text on the text field and for output through text field we have used the method step text right so we had we are now comfortable in taking input and output through text field then we have also done a output on label it is done in a similar method with the method set text and then we've also learnt all about printing our output or showing our output on our dialog box that is a pop-up window so we did that with J option thing not show message dialog and null or this and then any message that you want to display welcome so we have learnt these three we have learnt to take input and output on a frame through three different mediums we have also learned how to change the name of a component in our Java in our new jframe 2 we have changed the name of our text field to t 1 so that is what we have learned that we can also change the name of our component and the same name that you had then you have to use that in your coding then you so far we have declared our variables in integer that is an int and in a string and then we have also learned while taking an input that everything every time you are taking input from a text field it is going to give you an input in a string so you have to convert it into integer so the method that we have learned for converting your integer string value to integer is parse function so we have used so far we have used integer dot parse int makes it and then there was jtextfield 1.8 text so this is the method that we have used for conversion similarly if you want to convert your string to any other data type that is like double then you can write double dot parse double and either a variable name or a text field from where you are taking it input and similarly you can do that for your long short and float and so on so one by one we are going to address all of these data types and we will be using this parse function with double longshot and float also so far we have done our integer parsing we have done this now another thing that we have learned so far is convergent from integer to string and there are two methods in which we have used in displaying our output one is integer dot to string and another one is concatenating it with empty strings so we have done this much now there are few more important things which I want to discuss in our next application we are going to learn today about non GUI output that means non graphical user interface output so these are two statements which are going to help us to print an output not on the string not on the frame cut somewhere else it is going to print an output on the output window which is here right in your IDE there is a small window over here so your output will be displayed here now now coming back there are two methods two ways in printing your output in a non GUI output form system s capital remember s capital rest everything is small system dot out dot print and then this racket you can put a variable over here any variable which you have made clear then you have another way system dot out print ellen now print Ln here specifies that the next output will be displayed in next line if you want a gap of a line between two different output then you have to use system dot out print LM you are going to use both of them in our next application then we are going to learn about a few non character for formatting if you want to format your output on the screen with then we have two options /n + /t / and will take your output to the next line just like SOP l is slashing can be used with anything jtextfield a text area system.out.print and /t will leave 8 spaces just like it worked like back it is going to leave 8 spaces between two content and then we are going to learn few things more about concatenation so this is the work proportion for today this is what I am going to do in my next application so let's go to our Java NetBeans application I have already opened project NetBeans 1 I am I'm going to click right click on this new jframe form it is going to be jframe 3 so my new j feb 3 is there so this is what we are going to develop today few important things we will just take two input from the user – number input and we are going to deal we are going to do different things with them ok so label 1 label 2 and label 3 then two text fields and one button few important noun 1 number two it ditched the text field to empty and button sublet now I'm going to change this set me out now ok I'm going to change the font of all of these components clothes so here we are now I'm going to take one I'm going to display the output in this output window now so let's start coding we have to declare two variables I am declaring into X comma Y that's it and then I'm going to take an input of these two variables in teacher okay I'm going to take one more variable that isn't double today double T small one variable we are writing in this is another one we are writing in double double Y so in teacher dot parse int J next 31.8 text Y is equal to double dot parse double J text here – don't get text all right so now we have input for both the number one number we have taken in teacher and another number we have taken it double remember double is for any decimal values but it is not mandatory that you have to enter decimal values only if you have declared your variable in double you can also enter integer values so first of all I am going to print my output system on a non GI on an output window system dot out friend and I am writing here see for printing it on an output box in the using non-jew output you do not really require conversions you can use your variable straightaway if I'm going to write X plus y we will see what output it is going to give then I'm writing I am going to use conversion as well and I am writing empty string plus X plus y then I'm going to write empty string plus I'm going to put X plus y in a bracket X plus y basically I'm trying to do addition over here and then I'm going to write another system daughter friend and I am going to write X into y so see this plus is to concatenate X plus y with the empty string this plus over here is to concatenate X plus y the empty string but here we have protected X plus y with these brackets and I'll tell you why I have done that and then we are done this empty string plus concatenation operator this concatenate this plus is working as a concatenation operator and then this multiplication sign so I have used system.out.print so far and not system dot out print angle so we are going to sleep the okay so if I'm going to write here phi and num2 as for let's see what is the output that is given since double holds larger space or byte it can move larger bytes then integer so whatever is data type that can hold larger byte will overpower the other data type so your output will be when you are using two different data types your output will be displayed in the bigger data type so everything is displayed in double now X plus y is going to do an addition that is five plus four nine can you see nine over here this is correct okay next you have seen that I used empty string in the nitrogen plus X plus y now here is a catch the moment plus operator only plus operator remember the moment plus operator will see an empty string or any string for that matter it is going to convert the plus operator from addition to concatenation operator this is the reason here the results you can see is 54 we had given the value of five and four so it is it has concatenated them and not done the addition on them next you see that I have protected these X plus y value through the bracket can you see these brackets over here on yellow mark so because of those yellow mark my because brackets are always resolved before anything else so brackets will be solved so nine has been a have been done on the number nine has been formulated and then it has been converted into string and then multiplication now here this statement is exactly same like this one only the difference is plus operator here and multiplication here so only plus operator is going to get affected with the empty string no other operator multiplication division modulus it is going to work perfectly fine and it is given me the output 25 into 420 here they have not concatenated the result only this statement has concatenated the result see this statement carefully empty string plus X plus y so this has concatenated our two values five and four and it has given the result 54 it has not performed an addition to protect to make it perform addition we have to either protect it with the brackets there is another way of doing it if I'm going to write for example if I'm going to write system dot out dot print and X plus y and then teespring then it is going to do addition because it is going to get converted later on let's see how this is going to work three and four yes so you can see I have got the addition result for the first one which is X plus y then I've got the addition concatenation result three four again addition for the third one and multiplication for the fourth one and X plus y here the addition has been performed you can see the result of aging but now you can see that this has been achieved through system dot out print so system dot out print is going to give your result just next to each other and here I've used spaces there you can see spaces in between if I'm not used going to use these empty strings other space say it is going to print everything together now I'm going to use Ln instead of print so we will see the difference in an output over here again I'm going to run the file all right let's see the output now four and six you can see that output has been displayed in or in different line ten is for the first one X plus y 6 plus 4 is 10 the next one it has been concatenated output is 4 6 again this has been added because you protected our variable from the string through brackets then multiplication is easily done no other operator gets affected only plus then here we have done the addition first and then we convert it so we have got in a different line now we are going to learn to use slash in in /t as well so let's just learn that system dot out dot print if I'm going to write welcome to slash T my sauce / in for Java NetBeans okay so I have written this one statement system dot print so / and / t is when you want your content to be displayed in a particular order and you want to use them within the content so this is non-printable characters this will not be printed but they are going to format the output for six subject so you can see other statements have given the same output now welcome to there is a big space between my class that is approximately eight spaces my class for Java NetBeans because there is slash in that beep you so just displayed the resultant next one so so far we have used we have learnt about how to deal with double then we have to take an input in double double dot parse double this is the new function that we have used today new method conversion method that we've used today then we have learned how the concatenation plus sign can work as a concatenation operator the moment it is going to see any string and how we can protect it by putting bracket or writing it in a head of string and no other operator gets affected and then we have also learned about /t and slash end today so this was our walk for today thank you so much we will see you next time

One Comment

  1. Rohit Singh said:

    category comedy hai

    July 19, 2019

Leave a Reply

Your email address will not be published. Required fields are marked *