Skip to content

Commit 79899be

Browse files
committed
android projects
1 parent aebad02 commit 79899be

File tree

18 files changed

+87
-5
lines changed

18 files changed

+87
-5
lines changed
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.

JavaTestMahesh/src/com/mahesh/exceptionHandelling/ClassCast.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class ClassCast {
44
public static void main(String[] args) {
55
try {
6-
Object obj = new Integer(100);
6+
Object obj = new Integer(10);
77
System.out.println((float) obj);
88
} catch (ClassCastException e) {
99
System.out.println("Check the casting");

JavaTestMahesh/src/com/mahesh/exceptionHandelling/Example.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public Example(String message) {
1212
static {
1313
/* Store the first 10 characters of the input message. */
1414
subMessage = message.substring(0, 10);
15+
1516
}
1617

1718
public String getSubMessage() {

JavaTestMahesh/src/com/mahesh/exceptionHandelling/ExceptionChecked.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99

1010
public class ExceptionChecked {
1111
public static void main(String args[]) {
12-
String content = "Hello Mahesh";
12+
String content = "Hello Vishwa";
1313
FileInputStream fis = null;
1414
try {
15-
fis = new FileInputStream("C:/Softgen/mahesh.txt");
15+
fis = new FileInputStream("D:/java programs/vishwa.txt");
1616
} catch (FileNotFoundException fnfe) {
1717
System.out.println("The specified file is not "
1818
+ "present at the given path");
1919
}
2020
int k;
2121
try {
22-
File file = new File("C:/Softgen/mahesh.txt");
22+
File file = new File("D:/java programs/vishwa.txt");
2323
// if file doesnt exists, then create it
2424
if (!file.exists()) {
2525
file.createNewFile();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.mahesh.exceptionHandelling;
2+
3+
4+
public class VariableDemo {
5+
static int count = 0;
6+
7+
public void increment(){
8+
count++;
9+
}
10+
11+
static{
12+
System.out.println("Static value");
13+
}
14+
15+
public static void main(String[] args) {
16+
VariableDemo obj1 = new VariableDemo();
17+
VariableDemo obj2 = new VariableDemo();
18+
System.out.println("Obj1: count is = " + obj1.count);
19+
System.out.println("Obj2: count is = " + obj2.count );
20+
obj1.increment();
21+
System.out.println("Obj2: count is = " + obj2.count );
22+
obj2.increment();
23+
24+
System.out.println("Obj1: count is = " + obj1.count);
25+
26+
}
27+
28+
}
118 Bytes
Binary file not shown.
118 Bytes
Binary file not shown.
403 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)