Sunday, April 17, 2016

If and User Input




Today I learned how to write if statements in java. This is done by typing if(condition) {execute}. If the condition is met the code will proceed. In if statements you can add an else. This allows you to execute something else, if your condition isn’t met. I also looked at getting a user input. This is just when you ask the user to input a string or integer, and then you print that value.  This is done using a scanner class. When dealing with classes you must import a statement at the top of the class file that imports the scanner class, so the program knows where to find it.

No comments:

Post a Comment