Fields and methods are declared inside a class
impot java.util.*;
public class CalendarTesting {
public static void main(String[] args) {
GregorianCalendar today, yesterday;
}
}
public class BootCamp {
public static void main(String[] args) {
BootCamp a, b;
a = new BootCamp();
b = new BootCamp();
}
}
public class BootCamp {
public static void main(String[] args) {
BootCamp a, b;
a = new BootCamp();
b = a;
}
}
public class BootCamp {
public static void main(String[] args) {
BootCamp a;
a = new BootCamp();
a.printSomething();
}
public static void printSomething() {
System.out.println("Hello BootCamp 2016");
}
}
public class BootCamp {
//Public and private variables
public int number1, number2;
private boolean visible;
private int javaProgramming;
//Private method
private void setNumbers(int one, int two) {
number1 = one;
number2 = two;
}
//Public method
public void changeNumbers() {
setNumbers(1,9);
}
}
public class BootCampTest {
public static void main(String[] args) {
BootCamp a;
a = new BootCamp();
a.changeNumbers();
a.number1 = 10;
a.javaProgramming = 1;
a.setNumber(10,11);
}
}
public class BootCamp {
public static void main(String[] args) {
int x;
x = 0;
if (x = 10) {
int y = 10;
System.out.println("x and y:" + x + y);
x = y * 2;
}
y=100;
System.out.println("x is: "+x);
}
}
public class BootCamp {
BootCamp() {
//Do nothing
}
public static void main(String[] args) {
BootCamp a = new BootCamp();
}
}
import java.util.Calendar;
public class FindDay {
public static String weekDayName(int weekNumber) {
switch (weekNumber) {
case Calendar.MONDAY: return "Monday";
case Calendar.TUESDAY: return "Tuesday";
case Calendar.WEDNESDAY: return "Wednesday";
case Calendar.THURSDAY: return "Thursday";
case Calendar.FRIDAY: return "Friday";
case Calendar.SATURDAY: return "Saturday";
case Calendar.SUNDAY: return "Sunday";
default: return "Invalid day";
}
}
public static void main(String args[]) throws Exception {
FindDay today = new FindDay();
System.out.println(FindDay.weekDayName(4));
}
}
String toString()
static String toString(int i)
public class TestingToString {
public static void main(String[] args) {
Integer variable1 = 2016;
int variable = 2016;
System.out.println(variable1.toString());
System.out.println(Integer.toString(2016));
System.out.println(variable.toString()); //Correct?
}
}
public boolean equals(Object obj)
public class TestingEquals {
public static void main(String[] args) {
String str1 = new String("BootCamp 2016");
String str2 = new String("Learning OOP");
if (! str1.equals(str2)) {
System.out.println("They are not");
} else {
System.out.println("They are");
}
}
}
int[] array = new int[]{1,4,5,6};
System.out.println("The size of array is"+ array.length);
String[] array = new String[]{"Hello BootCampers"," how are you"};
System.out.println(Arrays.toString(array));
double avg = (double) 12/5
int rnd = (int) (29.4/10.0)
Integer xd = (Integer) rnd
Example 1:
x = 10;
y = ++x;
Example 2:
x = 10;
y = x++;
Example 1:
x = 10;
y = ++x;
x = 11 and y = 11
Example 2:
x = 10;
y = x++;
x = 11 and y = 10
First: 8, Second: 116
[10, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[9, 10, 1, 2, 3, 4, 5, 6, 7, 8]
[8, 9, 10, 1, 2, 3, 4, 5, 6, 7]
[7, 8, 9, 10, 1, 2, 3, 4, 5, 6]
[6, 7, 8, 9, 10, 1, 2, 3, 4, 5]
[5, 6, 7, 8, 9, 10, 1, 2, 3, 4]
[4, 5, 6, 7, 8, 9, 10, 1, 2, 3]
[3, 4, 5, 6, 7, 8, 9, 10, 1, 2]
[2, 3, 4, 5, 6, 7, 8, 9, 10, 1]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]