Study Guide - Information Systems
Study Guide - Information Systems
Notes to self
- Scanner sc = new Scanner (System.in); = required for user input
- _____ = sc.nextInt(); = user input
- System.exit (1) = Exit
- You call methods with an instance
Count
- Coders use count in order to keep iterations for a loop
Class
- You can think of a class as a code segment
-------------------------------------------------------------------------------------------------------------------------------
public static void main(String [] args)
{
System. out.println(“My First Project”);
}
-------------------------------------------------------------------------------------------------------------------------------
main Method
- Whenever a java program starts, it looks for a method called main.
- It will then execute any code within the curly brackets for main
- The parts between the round brackets of main are something called command-line
arguments
Public
- public means that the method can be seen outside of this class
Static
- static means that you don’t have to create a new object
Void
- void means it doesn’t return a value - it just gets on with it
How to share Java Program
https://www.homeandlearn.co.uk/java/sharing_your_java_programmes.html
VARIABLES
- Programs work by manipulating data placed in memory
- The data can be numbers, text, pointers to other memory areas
- The data is given a name so that it can be recalled whenever it is needed
- The name and its value is known as a variable
- Variable names cannot:
- Start with a number
- Variable names cant be the same as java keywords (words that turn blue ex.int)
- They cannot have spaces
- Variable names are case sensitive
- To store something in the variable you type an equals sign and then the value you want to
store
---------------------------------------------------------------------------------------------------------------------------
-
public static void main (String[] args)
{
int first_number;
first_number = 10;
If Statements
-------------------------------------------------------------------------------------------------------------------------------
if (Statement)
{
}
if(user<18)
{
}
-------------------------------------------------------------------------------------------------------------------------------
Symbols/Assignment
< Less than
== Exactly equal to
++ + 1
&& AND
|| OR
== HAS A VALUE OF
! NOT
else if ( user > 18 && user < 40 )
else if (user == 45 || user == 50)
Loops
for ( start_value; end_value; increment_number ) {
//YOUR_CODE_HERE
}
for(loopVal =0; loopVal < end_value; loopVal++){}
Method