Skip to content

Commit 58f695e

Browse files
Java Codes
1 parent d9ed7b9 commit 58f695e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1359
-0
lines changed

AREA.class

358 Bytes
Binary file not shown.

AccessModifier.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class Account{
2+
public String name;
3+
protected String email;
4+
private String password;
5+
6+
public String getPassword(){
7+
return this.password;
8+
}
9+
public void setPassword(String pass){
10+
this.password=pass;
11+
}
12+
13+
}
14+
15+
16+
17+
18+
19+
20+
public class AccessModifier {
21+
public static void main(String[] args) {
22+
Account account1=new Account();
23+
account1.name="Saud ahmed";
24+
account1.email="[email protected]";
25+
account1.setPassword("abcd");
26+
System.out.println(account1.getPassword());
27+
28+
}
29+
30+
}

ArrayList1.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import java.util.ArrayList;
2+
3+
public class ArrayList1 {
4+
public static void main(String[] args) {
5+
ArrayList<Integer> l1= new ArrayList<>();
6+
ArrayList<Integer> l2 =new ArrayList<>(5) ;
7+
l1.add(6);
8+
l1.add(5);
9+
10+
l1.add(4);
11+
l1.add(2);
12+
l2.add(10);
13+
l2.add(20);
14+
l2.add(40);
15+
l2.add(30);
16+
17+
l1.add(0,5);
18+
l1.add(0,1);
19+
20+
l1.set(1, 121);
21+
22+
l1.addAll(l2);
23+
//l1.clear();
24+
25+
26+
l1.add(0,5);
27+
System.out.println(l1.contains(27));
28+
System.out.println(l1.indexOf(2));
29+
30+
31+
for(int i=0;i<l1.size();i++)
32+
{
33+
34+
System.out.print(l1.get(i));
35+
System.out.print(", ");
36+
37+
}
38+
}
39+
40+
}

ArrayList2.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import java.util.ArrayList;
2+
3+
public class ArrayList2 {
4+
public static void main(String [] args)
5+
{
6+
ArrayList<String> name=new ArrayList<>();
7+
name.add("Saud");
8+
System.out.println(name);
9+
10+
}
11+
12+
}

Bracnching.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class Bracnching {
2+
public static void main(String[] args) {
3+
int i;
4+
for ( i=0; i<10;i++)
5+
{
6+
7+
8+
9+
10+
}
11+
if(i<3)
12+
{
13+
14+
15+
}
16+
System.out.println(i);
17+
18+
19+
}
20+
21+
}

CellPhone.class

377 Bytes
Binary file not shown.

CellPhone.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class function{
2+
3+
public void ringing()
4+
{
5+
System.out.println("phone is Ringing");
6+
}
7+
public void vibration()
8+
{
9+
System.out.println(" is it vibration");
10+
}
11+
public void call()
12+
{
13+
System.out.println("your are calling me");
14+
}
15+
}
16+
17+
18+
19+
20+
21+
public class CellPhone {
22+
public static void main(String[] args)
23+
{
24+
function ph=new function();
25+
ph.call();
26+
ph.vibration();
27+
ph.ringing();
28+
}
29+
30+
}

Collection1.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import java.util.Stack;
2+
3+
public class Collection1 {
4+
public static void main(String[] args) {
5+
6+
Stack < Integer > obj = new Stack <Integer>();
7+
obj.push(5);
8+
obj.push(6);
9+
obj.push(4);
10+
obj.push(10);
11+
12+
13+
System.out.println(obj.pop());
14+
System.out.println(obj);
15+
16+
17+
18+
}
19+
20+
}

Const.class

395 Bytes
Binary file not shown.

Const.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
class MainEmployee
3+
{
4+
public MainEmployee()
5+
{
6+
int id=54;
7+
String name="Saud ahmed";
8+
}
9+
10+
private int id;
11+
private String name;
12+
13+
public String getName()
14+
{
15+
return name;
16+
}
17+
public void setName(String n)
18+
{
19+
this.name=n;
20+
}
21+
public void setid(int i)
22+
{
23+
this.id=i;
24+
}
25+
public int getid()
26+
{
27+
return id;
28+
}
29+
}
30+
31+
32+
public class Const {
33+
public static void main(String[] args)
34+
{
35+
MainEmployee me=new MainEmployee();
36+
37+
me.setName("Saud ahmed");
38+
me.setid(54);
39+
40+
System.out.println(me.getid());
41+
System.out.println(me.getName());
42+
43+
44+
}
45+
46+
}

Date.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import java.time.LocalDate;
2+
import java.time.LocalDateTime;
3+
import java.time.LocalTime;
4+
import java.time.format.DateTimeFormatter;
5+
6+
public class Date {
7+
public static void main(String[] args) {
8+
// LocalDate obj = LocalDate.now();
9+
// System.out.println(obj);
10+
11+
// LocalDate d = LocalDate.now();
12+
// LocalTime t= LocalTime.now();
13+
// LocalDateTime ti =LocalDateTime.now();
14+
// System.out.println("date=" +d);
15+
// System.out.println("Time =" +t);
16+
// System.out.println("Date &Time =" +ti);
17+
18+
LocalDateTime dt =LocalDateTime.now();
19+
System.out.println("Before formatting =" +dt);
20+
DateTimeFormatter f =DateTimeFormatter.ofPattern("dd-MM-yy HH:mm:ss");
21+
22+
String formattedDate = dt.format(f);
23+
System.out.println("After Formatting=" +formattedDate);
24+
25+
26+
27+
28+
29+
}
30+
31+
}

Date1.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import java.time.LocalDate;
2+
import java.time.LocalDateTime;
3+
4+
public class Date1 {
5+
public static void main(String[] args) {
6+
LocalDate obj = LocalDate.now();
7+
System.out.println(obj);
8+
9+
LocalDateTime dt = LocalDateTime.now();
10+
System.out.println(dt);
11+
12+
Calender c =Calender.getInstance();
13+
System.out.println("The current Date is = "+c.getTime());
14+
15+
16+
}
17+
18+
}

Employee.class

541 Bytes
Binary file not shown.

Enum.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
enum Day{
3+
Running,Failed,Success,Pending;
4+
5+
}
6+
7+
8+
9+
public class Enum {
10+
public static void main(String[] args) {
11+
int i = 5;
12+
Day obj =Day.Pending;
13+
}
14+
15+
16+
17+
18+
19+
}
20+

ExceptionError.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.util.Scanner;
2+
3+
public class ExceptionError {
4+
public static void main(String[] args) {
5+
int [] marks=new int[3];
6+
marks[0]=56;
7+
marks[1]=30;
8+
marks[2]=25;
9+
10+
Scanner sc =new Scanner(System.in);
11+
System.out.println("ENter the array of index=");
12+
int inde= sc.nextInt();
13+
14+
System.out.println("Ebetr the number divide value =");
15+
int number=sc.nextInt();
16+
17+
try{
18+
System.out.println("The value of array index enetered is = " +marks[inde]);
19+
System.out.println("The value f /number is = " +marks[inde]/number);
20+
}
21+
catch(Exception e)
22+
{
23+
System.out.println("!!!!Some exception Happen!!!");
24+
System.out.println(e);
25+
}
26+
}
27+
28+
}

Excersie.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.Scanner;
2+
3+
public class Excersie {
4+
public static void main(String[] args) {
5+
int a;
6+
int b;
7+
System.out.println("Enter the number =");
8+
Scanner sc = new Scanner (System.in);
9+
int num= sc.nextInt();
10+
for(a=0;a<=num;a++)
11+
{
12+
for(b=0;b<a;b++)
13+
{
14+
System.out.print("*");
15+
}
16+
System.out.println();
17+
18+
}
19+
}
20+
21+
}

0 commit comments

Comments
 (0)