Complete Java Course Overview
Complete Java Course Overview
GUI................................................................................................................................................................... 16
Auston java....................................................................................................................................................... 17
import [Link].*;
import [Link];
import [Link];
import [Link];
}
[Link]("Byeee!");
47. FileReader
try {
FileReader fileReader = new FileReader("[Link]");
int data = [Link]();
while (data != -1){
[Link]((char)data);
data = [Link]();
}
[Link]();
} catch (FileNotFoundException e) {
[Link]();
} catch (IOException e) {
[Link]();
}
46. FileWriter
try {
FileWriter fileWriter = new FileWriter("[Link]");
[Link]("Thii is heading\n this is subheading");
[Link]("\n(A paper by Tayzar)");
[Link]();
} catch (IOException e) {
[Link]();
}
44. Exception
Scanner scanner = new Scanner([Link]);
try{
[Link]("Enter a whole number to divide: ");
int x = [Link]();
double z = x/y;
[Link]("The answer is " +z);
}
catch (ArithmeticException e){
[Link]("you can't divde a zero!");
}
catch (InputMismatchException e){
[Link]("PLEASE Enter a whole number!");
}
catch (Exception e){
[Link]("Someting went wrong");
}
finally {
[Link]();
}
43. Dynamic Polymorphism
Animal animal;
Scanner scanner = new Scanner([Link]);
[Link]("What animal you want?");
[Link]("Press [Link] or [Link]: ");
int choice = [Link]();
if (choice == 1){
animal = new Dog();
[Link]();
}
else if (choice == 2){
animal = new Cat();
[Link]();
}
else {
animal = new Animal();
[Link]();
}
public class Animal {
@Override
public void speak(){
[Link]("Dog goes *bark*");
}
}
public class Cat extends Animal{
@Override
public void speak(){
[Link]("Cat goes *Meow*");
}
}
42. polymorphish
void go(){
}
}
public class Car extends Vehicles{
@Override
void go(){
[Link]("This car is moving");
}
}
41. intrfaces
Fish fish = new Fish();
[Link]();
[Link]();
@Override
public void flee() {
}
}
@Override
public void hunt() {
[Link]("*It is hunting*");
}
}
public class Rabbit implements Prey {
@Override
public void flee() {
[Link]("*this is fleeing*");
}
}
void flee();
}
public interface Predator {
void hunt();
}
[Link](car1);
[Link](car2);
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
}
public String getMake(){
return make;
}
public String getModel(){
return model;
}
public int getYear(){
return year;
}
39. Encapsulation
@Override
void go(){
[Link]("This car is moving");
}
String power;
Hero(String name, int age, String power){
super(name,age);
[Link] = power;
}
public String toString() {
return [Link]() + [Link] + "\n";
}
}
void speak(){
[Link]("Animal speaks");
}
}
public class dog extends Animal{
@Override
void speak(){
[Link]("The dogs *bark*");
}
34. Inheritant
[Link]([Link]);
[Link]([Link]);
double speed;
void go(){
[Link]("This vehicle is moving");
}
void stop(){
[Link]("This vehicle is stopped");
}
}
public class Car2 extends Vehicle{
int wheels = 4;
int doors = 4;
}
public class Bicycle extends Vehicle{
int wheels = 2;
int pedals = 2;
}
33. Static keywords
// [Link]([Link]);
[Link]();
Friends(String name){
[Link] = name;
numbersOfFriends++;
}
static void displaysFriends(){
[Link]("You have "+numbersOfFriends+ " friends");
}
}
[Link](car1);
[Link](car2);
[Link](refrigerator[0].name);
[Link](refrigerator[1].name);
[Link](refrigerator[2].name);
// [Link]([Link]);
// [Link]([Link]());
[Link](car);
public class car {
String bread;
String saucse;
String cheese;
String topping;
[Link] = bread;
[Link] = saucse;
}
Pizza(String bread, String saucse, String cheese){
[Link] = bread;
[Link] = saucse;
[Link] = cheese;
}
Pizza(String bread, String saucse, String cheese, String topping){
[Link] = bread;
[Link] = saucse;
[Link] = cheese;
[Link] = topping;
}
}
// [Global]
Random random;
int number;
DiceRoller(){
random = new Random();
number = 0;
roll();
}
void roll(){
number = [Link](6)+1;
[Link](number);
}
}
/*
// [Local]
DiceRoller(){
Random random = new Random();
int number = 0;
roll(random, number);
}
void roll(Random random, int number){
number = [Link](6)+1;
[Link](number);
}
*/
/*
27. Constructors
Human human1 = new Human("Jhon", 12, 23.4);
Human human2 = new Human("Hagai", 34, 234.4);
[Link]([Link]);
[Link]([Link]);
[Link]();
[Link]();
String name;
int age;
double weight;
void eat(){
[Link]([Link] +" is eating");
}
void drink(){
[Link]([Link]+" is drinking *brup*");
}
26. objects(OOP)
[Link]();
[Link]();
24. printf
//[Coversion Characters]
// [Link]("%d %c %f %s %b", age, symbol, gpa, name, Male);
//[Width]
//[Link]("Hello %10s", name);
//[Precision]
//[Link]("You have %.2f", gpa);
//[flag]
[Link]("You have %,f", gpa);
//10f -10f -f +f 020f
add(1, 2);
add(1,2,3);
add(1,2,3,4);
}
static int add(int x, int y){
int z = x + y;
[Link]("This is the overloaded method #1");
[Link](z);
return z;
}
static int add(int x, int y, int a){
int z = x + y + a;
[Link]("This is the overloaded method #2");
[Link](z);
return z;
}
static int add(int x, int y, int a, int b){
int z = x + y + a + b;
[Link]("This is the overloaded method #3");
[Link](z);
return z;
}
static double add(double x, double y){
double z = x + y;
[Link]("This is the overloaded method #4");
[Link](z);
return z;
}
static double add(double x, double y, double a){
double z = x + y + a;
[Link]("This is the overloaded method #5");
[Link](z);
return z;
}
static double add(double x, double y, double a, double b){
double z = x + y + a + b;
[Link]("This is the overloaded method #6");
[Link](z);
return z;
}
}
22. Methods
add(2,4);
}
Integer a = 123;
Double d = 2.3;
Boolean b = true;
String s = "Hey";
Character c = '=';
// [Link](bakeryList);
// [Link]([Link](0));
combine
[Link](productList);
[Link](drinkList);
[Link](bakeryList);
// [Link](groceryList);
[Link]([Link](0).get(0));
[Link](result);
16. 2D arrays
String[][] currentListOfMedicince ={
{"Bitarmin", "Biojustsis", "Batmintin"},
{"Arenba", "Amberma", "Aquain"},
{"Cetinmin", "Cellgrow", "Cattalim"},
{"Digging", "Dulingo", "Doover"}
};
15. Arrays
subjects[0] = "Math";
subjects[1] = "Science";
subjects[2] = "Chemical";
[Link] loop
[Link] loop
while ([Link]()){
// excutes the lines of code as long as that conditons still remain true
[Link]("Enter your name: ");
name = [Link]();
do{
// excutes the lines of code as long as that conditons still remain true
[Link]("Enter your name: ");
name = [Link]();
}while ([Link]());
int temp;
Scanner scanner = new Scanner([Link]);
[Link]("Enter your temp: ");
temp = [Link]();
[Link](temp);
}
else {
[Link]("You are still in the game");
}
2. Variables
String x = "Water";
String y = "Acid";
String temp;
// x = y Acid
// y = x Water
[Link]("x: " +x);
[Link]("y: " +y);
4. User input
5. Experssion
// int appleSlices = 4;
// double appleSlices = 4;
// appleSlices = appleSlices + 1;
// appleSlices += 1;
// appleSlices ++; // just one
// appleSlices = appleSlices / 3;
// [Link](appleSlices);
7. Math class
double a = 23.45;
double b = -30.0;
double c = [Link](a);
//max, min, abs, sqrt, pow, round, ceil, floor
[Link](c);
double x,y,z;
Scanner scanner = new Scanner([Link]);
[Link]("Enter the side x: ");
x = [Link]();
[Link]("Enter the side y: ");
y = [Link]();
// hypotenuse formula c = squaroot of a square + b square
z = [Link]((x*x)+(y*y));
[Link]("The hypotenuse is: " +z);
[Link]();
[Link] numbers
9. if statements
int typesOfGuess = 1;
// Scanner scanner = new Scanner([Link]);
// [Link]("Enter between 1 to 3");
// [Link]("Enter your number: ");
if (typesOfGuess == 1){
[Link]("You are a VIP guess!");
}
else if(typesOfGuess == 2){
[Link]("You are an entertainer.");
}
else if(typesOfGuess == 3){
[Link]("You are just a normal guess.");
}
else {
[Link]("You are not allowed to go in.");
}
[Link] statments
int gpa = 3;
switch (gpa) {
case 2:
[Link]("You did normal!");
break;
case 3:
[Link]("You did average!");
break;
case 4:
[Link]("You did awesome!");
break;
case 5:
[Link]("You did ellcentent!");
break;
default:
[Link]("Keep it up!");
}
GUI
new mouselistener();
import [Link].*;
import [Link].*;
import [Link];
import [Link];
JLabel label;
ImageIcon a;
ImageIcon b;
ImageIcon c;
ImageIcon d;
mouselistener() {
[Link](JFrame.EXIT_ON_CLOSE);
[Link](500, 500);
[Link](new FlowLayout());
[Link](a);
[Link](label);
[Link]();
[Link](null);
[Link](true);
}
@Override
public void mouseClicked(MouseEvent e) {
@Override
public void mousePressed(MouseEvent e) {
[Link](b);
@Override
public void mouseReleased(MouseEvent e) {
[Link](c);
@Override
public void mouseEntered(MouseEvent e) {
[Link](d);
@Override
public void mouseExited(MouseEvent e) {
[Link](a);
}
}
JLabel label;
mouselistener(){
[Link](JFrame.EXIT_ON_CLOSE);
[Link](500, 500);
[Link](null);
[Link](label);
[Link](true);
}
@Override
public void mouseClicked(MouseEvent e) {
//[Link]("You clicked the mouse ");
}
@Override
public void mousePressed(MouseEvent e) {
[Link]("You pressed the mouse ");
[Link]([Link]);
}
@Override
public void mouseReleased(MouseEvent e) {
[Link]("You released the mouse ");
[Link]([Link]);
@Override
public void mouseEntered(MouseEvent e) {
[Link]("You entered the component ");
[Link]([Link]);
}
@Override
public void mouseExited(MouseEvent e) {
[Link]("You existed the component ");
[Link]([Link]);
}
}
new keyListener();
import [Link].*;
import [Link].*;
import [Link];
import [Link];
JLabel label;
ImageIcon icon;
keyListener(){
[Link](JFrame.EXIT_ON_CLOSE);
[Link](500, 500);
[Link](this);
[Link](null);
[Link]().setBackground([Link]);
[Link](label);
[Link](true);
}
@Override
public void keyTyped(KeyEvent e) {
switch ([Link]()){
case 'a' :
[Link]([Link]()-10, [Link]());
break;
case 'w' :
[Link]([Link](), [Link]()-10);
break;
case 's' :
[Link]([Link]()+10, [Link]());
break;
case 'd' :
[Link]([Link](), [Link]()+10);
break;
}
@Override
public void keyPressed(KeyEvent e) {
switch ([Link]()){
case 37 :
[Link]([Link]()-10, [Link]());
break;
case 38 :
[Link]([Link](), [Link]()-10);
break;
case 39 :
[Link]([Link]()+10, [Link]());
break;
case 40 :
[Link]([Link](), [Link]()+10);
break;
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}
new colorselecter();
import [Link].*;
import [Link].*;
import [Link];
import [Link];
JButton button;
JLabel label;
colorselecter() {
[Link](JFrame.EXIT_ON_CLOSE);
[Link](new FlowLayout());
[Link](label);
[Link](button);
[Link]();
[Link](true);
@Override
public void actionPerformed(ActionEvent e) {
if ([Link]() == button){
[Link](color);
// [Link](color);
}
}
}
new fileselecter();
import [Link].*;
import [Link].*;
import [Link];
import [Link];
import [Link];
JButton button;
fileselecter(){
[Link](JFrame.EXIT_ON_CLOSE);
[Link](new FlowLayout());
button = new JButton("Select file");
[Link](this);
[Link](button);
[Link]();
[Link](true);
@Override
public void actionPerformed(ActionEvent e) {
if ([Link]() == button){
JFileChooser fileChooser = new JFileChooser();
[Link](new File("."));
if (respones == fileChooser.APPROVE_OPTION){
[Link](file);
}
}
}
}
new menu();
import [Link].*;
import [Link].*;
import [Link];
JMenuBar menuBar;
JMenu fileMenu;
JMenu editMenu;
JMenu helpMenu;
JMenuItem loadItem;
JMenuItem saveItem;
JMenuItem exitItem;
ImageIcon saveIcon;
ImageIcon loadIcon;
ImageIcon existIcon;
menu(){
[Link](JFrame.EXIT_ON_CLOSE);
[Link](500, 500);
[Link](new FlowLayout());
[Link](this);
[Link](this);
[Link](this);
[Link](loadIcon);
[Link](saveIcon);
[Link](existIcon);
[Link](KeyEvent.VK_F); // Alt + f to file
[Link](KeyEvent.VK_E); // Alt + e to file
[Link](KeyEvent.VK_H); // Alt + h to file
[Link](KeyEvent.VK_S); // S to save
[Link](KeyEvent.VK_L); // L to load
[Link](KeyEvent.VK_E); //E tp to exist
[Link](loadItem);
[Link](saveItem);
[Link](exitItem);
[Link](fileMenu);
[Link](editMenu);
[Link](helpMenu);
[Link](menuBar);
[Link](true);
}
@Override
public void actionPerformed(ActionEvent e) {
if ([Link]() == loadItem){
[Link]("Loaded file");
}
if ([Link]() == exitItem){
[Link](0);
}
if ([Link]() == saveItem){
[Link]("saved file");
}
}
}
new progressbar();
import [Link].*;
import [Link].*;
progressbar(){
[Link](0);
[Link](0,0,420, 50);
[Link](true);
[Link](new Font("MV Boli", [Link], 25));
[Link]([Link]);
[Link]([Link]);
[Link](bar);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](420, 420);
[Link](null);
[Link](true);
fill();
}
public void fill(){
}
63. Slider
new Slider();
import [Link].*;
import [Link].*;
import [Link].*;
Slider(){
[Link](true);
[Link](10);
[Link](true);
[Link](25);
[Link](true);
[Link](new Font("MV Boli", [Link], 15));
[Link](new Font("MV Boli", [Link], 25));
//[Link]([Link]);
[Link]([Link]);
[Link](this);
[Link](slider);
[Link](label);
[Link](panel);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](500, 500);
[Link](true);
}
@Override
public void stateChanged(ChangeEvent e) {
}
}
[Link] BOX
new combobox();
import [Link].*;
import [Link].*;
import [Link];
import [Link];
JComboBox comboBox;
combobox() {
[Link](JFrame.EXIT_ON_CLOSE);
[Link](new FlowLayout());
[Link](comboBox);
[Link]();
[Link](true);
}
@Override
public void actionPerformed(ActionEvent e) {
if ([Link]() == comboBox)
{
[Link]([Link]());
}
}
}
new RadioButton();
JRadioButton pizzaButton;
JRadioButton bumgerButton;
JRadioButton hotdogButton;
ImageIcon pizzaIcon;
ImageIcon burgerIcon;
ImageIcon hotdogIcon;
RadioButton(){
[Link](JFrame.EXIT_ON_CLOSE);
[Link](new FlowLayout());
[Link](this);
[Link](this);
[Link](this);
[Link](pizzaIcon);
[Link](burgerIcon);
[Link](hotdogIcon);
[Link](pizzaButton);
[Link](bumgerButton);
[Link](hotdogButton);
[Link]();
[Link](true);
}
@Override
public void actionPerformed(ActionEvent e) {
if ([Link]() == pizzaButton){
[Link]("You order pizza");
}
else if ([Link]()== bumgerButton){
[Link]("You order burger");
}
else if([Link]() == hotdogButton){
[Link]("You order hotdog");
}
}
}
new CheckBox();
import [Link].*;
import [Link].*;
import [Link];
import [Link];
public class CheckBox extends JFrame implements ActionListener {
JButton button;
JCheckBox checkBox;
CheckBox(){
[Link](JFrame.EXIT_ON_CLOSE);
[Link](new FlowLayout());
[Link](button);
[Link](checkBox);
[Link]();
[Link](true);
}
@Override
public void actionPerformed(ActionEvent e) {
if ([Link]() == button){
[Link]([Link]());
}
}
}
new TextField();
import [Link].*;
import [Link].*;
import [Link];
import [Link];
public class TextField extends JFrame implements ActionListener {
JButton button;
JTextField textField;
TextField(){
[Link](JFrame.EXIT_ON_CLOSE);
[Link](new FlowLayout());
[Link](button);
[Link](textField);
[Link]();
[Link](true);
}
@Override
public void actionPerformed(ActionEvent e) {
if ([Link]() == button){
// [Link](false);
[Link]("Hello " +[Link]());
}
}
}
[Link] Pane
// [Link](null, "This is Non-display", "Title",
JOptionPane.PLAIN_MESSAGE );
// [Link](null, "This is Non-display", "Title",
JOptionPane.INFORMATION_MESSAGE );
// [Link](null, "This is Non-display", "Title",
JOptionPane.QUESTION_MESSAGE );
//[Link](null, "This is Non-display", "Title",
JOptionPane.WARNING_MESSAGE );
// [Link](null, "This is Non-display", "Title",
JOptionPane.ERROR_MESSAGE );
// int answer = [Link](null, "What is your fucking name
you little bitch?", "Title", JOptionPane.YES_NO_CANCEL_OPTION );
// [Link]([Link](null, "What is your fucking
name you little bitch?", "Title", JOptionPane.YES_NO_CANCEL_OPTION ));
// String name = [Link]("What is your name?: ");
// [Link]("Hello "+name);
[Link](
null,
"I am going to fucking kill you",
"Answer:",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE,
icon,
respones,
0);
}
new LanchPage();
import [Link].*;
import [Link];
import [Link];
[Link](JFrame.EXIT_ON_CLOSE);
[Link](400, 400);
[Link](null);
[Link](button);
[Link](true);
@Override
public void actionPerformed(ActionEvent e) {
if ([Link]()== button){
[Link]();
NewWindow myWindow = new NewWindow();
}
}
}
NewWindow(){
[Link](label);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](400, 400);
[Link](null);
[Link](true);
}
}
[Link] Pane
[Link](label1, JLayeredPane.DEFAULT_LAYER);
[Link](label2, [Link](2));
[Link](label3, JLayeredPane.DRAG_LAYER);
[Link](true);
[Link](new Button("1"));
[Link](new Button("2"));
[Link](new Button("3"));
[Link](new Button("4"));
[Link](new Button("5"));
[Link](new Button("6"));
[Link](new Button("7"));
[Link](new Button("8"));
[Link](new Button("9"));
[Link](panel1);
[Link](true);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
//---------------------sub panles------------------------------
[Link]([Link]);
[Link]([Link]);
[Link](Color.DARK_GRAY);
[Link]([Link]);
[Link]([Link]);
[Link](new BorderLayout());
[Link](panel6,[Link]);
[Link](panel7,[Link]);
[Link](panel8,[Link]);
[Link](panel9,[Link]);
[Link](panel10,[Link]);
//-----------------sub panles-----------------------------
[Link](panel1,[Link]);
[Link](panel2,[Link]);
[Link](panel3,[Link]);
[Link](panel4,[Link]);
[Link](panel5,[Link]);
52. buttons
new subFram();
import [Link].*;
import [Link].*;
import [Link];
import [Link];
JButton button;
JLabel label;
ImageIcon icon;
ImageIcon icon2;
subFram(){
[Link](JFrame.EXIT_ON_CLOSE);
[Link](null);
[Link](800, 800);
[Link](true);
[Link](button);
[Link](label);
}
@Override
public void actionPerformed(ActionEvent e) {
if ([Link]() == button){
[Link](true);
---------------------------------------------------------------------
import [Link].*;
import [Link];
import [Link];
[Link](JFrame.EXIT_ON_CLOSE);
[Link](null);
[Link](800, 800);
[Link](true);
[Link](button);
}
@Override
public void actionPerformed(ActionEvent e) {
if ([Link]() == button){
[Link]("Boo");
[Link](false);
}
}
-----------------------------------------------------------------------------------------------
import [Link].*;
import [Link];
import [Link];
JButton button;
ImageIcon icon;
JLabel label;
subFram(){
[Link](JFrame.EXIT_ON_CLOSE);
[Link](500, 500);
[Link](null);
[Link](true);
[Link](button);
[Link](label);
}
@Override
public void actionPerformed(ActionEvent e) {
if ([Link]() == button){
[Link](true);
}
}
[Link]
50. labels
[Link](JFrame.EXIT_ON_CLOSE);
// [Link](500,500);
// [Link](null);
[Link](true);
[Link](label);
[Link]();
// [Link]().setBackground([Link]);
49. GUI
import [Link].*;
import [Link].*;
MyFrame(){
double height =
[Link]([Link]("Enter Your height"));
// [Link](null, "You are " +height+ " cm
tall");
Auston java
int days = 1000;
int seconds = 864_00; // one day's seconds
int lightspeed = 186000;
long distance;
long conver_seconds;
switch (choice){
case 1:
balance += amount;
break;
case 2:
balance -= amount;
}