Java Computer Programming Chapter 2

Set of cards for basic java programming terms

20 cards   |   Total Attempts: 188
  

Cards In This Set

Front Back
Program necessities
Public class something { public static void main(string[] args) {}}
Print out a string on page
System.out.println("something");system.out.print("something");
Declaring and initializing a variable
type name = expression;first letter must be lower cased
Types of expressions
Literal= 0, 0.1, true, 'a'; int, double, charvariable= expressionoperation= expression operation expressionsome method calls= methodName(information)constant= something
Finding the remainder
int % int
Using classes from a package
Import package.classname; or import package.*; -a package is a collection of classes with a related purpose-must be at top of source code
Reading input
Import java.util.Scanner;...Scanner in = new Scanner(System.in)
System.out.println("Prompt to User")... in.nextlnt()....
System.out.println("Prompt to User")...in.nextDouble()...
In/decreasing variables by 1
++--
Adding comments for programmer
// comment/*blockcomment*/
Declaring a constant
Final type NAME = expression;
Math class
Import java.lang.math;Math.squrt(number);Math.pow(number, power);Math.abs(number);-and many more on api
Casting
(type) expression-changes expression into the type described
String Variables
String name = StringExpression;name = StringExpression;
String and char literals
String literal"text"char literal'char'-char is one character
String concatenation
StringExpressionA + StringExpressionB goes toStringExpressionAStringExpressionB