Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dipraj-howlader committed Sep 11, 2021
0 parents commit 54ced17
Show file tree
Hide file tree
Showing 18 changed files with 381 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Access_modifier/A.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package Access_modifier;

public class A {
public void display() {
System.out.println("HI I am private");
}
protected void display2() {
System.out.println("Hi I am protected");
}

void nothing() {
System.out.println("Default, We can only use in Same package");
}
}
5 changes: 5 additions & 0 deletions Access_modifier/B.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package Access_modifier;

public class B {

}
5 changes: 5 additions & 0 deletions Access_modifier/C.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package Access_modifier;

public class C {

}
10 changes: 10 additions & 0 deletions Access_modifier/test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package Access_modifier;

public class test {
public static void main(String[] args) {
A a = new A();
a.display();
a.display2();
a.nothing();
}
}
12 changes: 12 additions & 0 deletions Access_modifier2/CC.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package Access_modifier2;

import Access_modifier.A;

public class CC extends A {
public static void main(String[] args) {
CC aa= new CC();
aa.display();
aa.display2();
// aa.nothing();
}
}
61 changes: 61 additions & 0 deletions ExpressionHandaling/A.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package ExpressionHandaling;

import java.io.File;

public class A {

// expection handaling
// - Runtime Error means expection

int x = 10;
int y = 0;
int z= x / y;
// Arithmetic expection

String name = null;
char name2 = name.charAt(0);
//Null pointer expection

String name3 = "Dipraj";
char name4 = name3.charAt(9);
// String Index Out Of Bounds Expection

int num = Integer.parseInt("DIPURAJ");
// NumberFormet expection

File file = new File("../..///");
//File not Found expection

int[] a = new int[5];
a[5] = 32;
//Array INdex Out of bOund expection

// What is expection handling
// Handling runtime ERROR

// try
// catch
// finally
// throw
// throws
//this keywords are used to handle expection

try {

//code you want to monitor
// or maybe the code can show expection error
//if any expection will have found than try will throw it to the FIRST CATCH
}
catch( /* expection type e1 */ ) {
//Exception handler for expection
}
catch( /* expection type e2 */ )
{
//Exception handler for expection //Exception handler for expection
}
finally {
// block of code to be executed after try block
}


}
47 changes: 47 additions & 0 deletions ExpressionHandaling/ExpectionDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package ExpressionHandaling;

public class ExpectionDemo {
public static void main(String[] args) {

try {
int x = 10;
int y = 0;
int result = x/y;
System.out.println(result);
}

catch(ArrayIndexOutOfBoundsException e) {
System.out.println("Expection : "+e);
}
catch(ArithmeticException e) {
System.out.println("Expection : "+e);
}

finally {
System.out.println("Vai jani nah ki vul hocie");
}


System.out.println("Last line of the program");

//Another

try {
int [] a = new int[4];
a[4] = 5;

}
catch(ArrayIndexOutOfBoundsException e1) {
System.out.println("Expection : "+e1);
}
catch(Exception e2) {
System.out.println("Expection : "+e2);
}
finally {
System.out.println("Last line of the program");
}



}
}
17 changes: 17 additions & 0 deletions HashSett/HashSetDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package HashSett;

import java.util.HashSet;

public class HashSetDemo {
public static void main(String[] args) {

HashSet<String> fruits = new HashSet<String>();

fruits.add("Alu");
fruits.add("Orange");
fruits.add("Banana");

System.out.println(fruits);
System.out.println(fruits.size());
}
}
19 changes: 19 additions & 0 deletions Hashmap/Hashmapp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package Hashmap;

import java.util.HashMap;

public class Hashmapp {
public static void main(String[] args) {

HashMap<Integer, String> customar = new HashMap<Integer, String>();

//put get
customar.put(101, "Dipraj");
customar.put(102, "Sunu");
customar.put(130, "Anu");


System.out.println(customar.get(102));

}
}
38 changes: 38 additions & 0 deletions LinkedList/LinkEDLIST.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package LinkedList;

import java.util.LinkedList;

public class LinkEDLIST {

public static void main(String[] args) {

LinkedList<String> countryName = new LinkedList<String>();

countryName.add("Bangladesh");
countryName.add("India");
countryName.add("Pakistan");
countryName.add("China");

countryName.add(4, "Japan");
countryName.add(5, "Argentina");

countryName.addFirst("USA");
countryName.addLast("Afganistan");

for(String x : countryName) {
System.out.println(x);
}

countryName.remove(5);
countryName.removeFirst();


System.out.println(countryName);
System.out.println("Size of the list : " + countryName.size());

System.out.println( "5 " + "Element is : "+countryName.get(5));

}


}
22 changes: 22 additions & 0 deletions LinkedList/StudentList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package LinkedList;

public class StudentList {

String name ,className;
int id;

StudentList(int id, String name, String className){
this.id = id;
this.name = name;
this.className = className;

}

@Override

public String toString(){
return "ID : " + id + ", Name : " + name + ", Class : " + className;
}


}
30 changes: 30 additions & 0 deletions LinkedList/StudentListDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package LinkedList;

import java.util.LinkedList;

public class StudentListDemo {
public static void main(String[] args) {
// student link list

LinkedList<StudentList> list = new LinkedList<StudentList>();


// student create

StudentList s1 = new StudentList(1, "Dipraj", "XI");
StudentList s2 = new StudentList(2, "Sun", "XII");
StudentList s3 = new StudentList(3 , "Ayaon", "V");
StudentList s4 = new StudentList(4, "Avro", "I");

// adding student

list.add(s1);
list.add(s2);
list.add(s3);
list.add(s4);

for(StudentList o : list) {
System.out.println(o);
}
}
}
19 changes: 19 additions & 0 deletions StringComparison/Compare1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package StringComparison;

public class Compare1 {

public static void main(String[] args) {
//equals()
//Compares the original content of the string

String password1 = "Dipraj";
String password2 = "Dipraj";
String pass3 = new String("Dipraj");
String pass4 = new String("Dipraj");

System.out.println(pass3.equals(pass4));
// == compare the reference of the objects not the value
System.out.println(password1 == password2); //true
System.out.println(password1 == pass3); // false
}
}
19 changes: 19 additions & 0 deletions ToStringMethod/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ToStringMethod;

public class Person {

// to string method
String name;
int age;
Person(String name, int age ){
this.age = age;
this.name = name;
}

@Override
public String toString() {
return "Name : " + name + "\n" + "Age : "+ age;

}

}
11 changes: 11 additions & 0 deletions ToStringMethod/test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ToStringMethod;

public class test {
public static void main(String[] args) {

Person p1 =new Person("Dipraj",56);
Person p2 = new Person("Minhaj", 89);
System.out.println(p1); // toString Method
System.out.println(p2); //toString method
}
}
30 changes: 30 additions & 0 deletions TypeCasting/A.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package TypeCasting;

public class A {
// to convert data type from one to another

public static void main(String[] args) {
int x = 10;
double y = x; //implicit type casting
// Widening



double z=12.5;
int c = (int) z; // explicit type casting
//narrowing

// not primitive type casting
// 1. Upcasting
// 2. downcasting

Person p = new Teacher(); // upcasting
p.display();

Teacher t = (Teacher) new Person();
t.display(); //compile error

System.out.println(y +" " + c );

}
}
11 changes: 11 additions & 0 deletions TypeCasting/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package TypeCasting;

public class Person {

// super

void display() {
System.out.println("Perosn class");
}

}
11 changes: 11 additions & 0 deletions TypeCasting/Teacher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package TypeCasting;

public class Teacher extends Person {
//sub

@Override
void display() {
System.out.println("Teacher class");
}

}

0 comments on commit 54ced17

Please sign in to comment.