forked from CMPSC1500-Spring17/Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChapter 5
More file actions
54 lines (38 loc) · 1.42 KB
/
Chapter 5
File metadata and controls
54 lines (38 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
5.7
System.out.printf //print format-used to add things like , in long numbers ex. 100,000,000
%d works for decimal integer
%s for string
%f float-always prints at least one digit after decimal point
%e floats, but will be printed out in scientific notation
%flags#width#precision conventional format character
%10.2f gives a total of 10 spaces 2 means to the second decimal point "." counts as a space if empty space left in the 10 it adds empty space to the beginning of the number
%-10.2f adds empty space to the right
%010.2f changes empty space to 0's
functions
public static void main (string[]args)
public-anything can call functions
private- only this file can call your functions
static- always used
void- dont return anything. type that is returned by function. could be float string char boolean
main- name of function. No two functions in the same class can have the same name
String[]-what goes into the function
(type name,)
type is int, string, float
name can be anything start with a lowercase letter
private void printChessboardLine (boolean odd)
{
if (odd)
{
println("bwbwbwbw");
}
else
{
println("wbwbwbwbwb");
}
}
chapter 2 3 4 5 and beginning of 9
Arrays
int[] age; says that age will store an integer array
age=new int[sizeOfList]
age[3]; finds the value stored in section 3 of age
initially all spaces have a value of 0 for integers, and floats. booleans have false. strings have null