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="abc@gmail.com";
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+
}

0 commit comments

Comments
 (0)