Thanigai arasu Ruthirakotti

Greenhorn
+ Follow
since Jan 24, 2015
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Thanigai arasu Ruthirakotti

Hello Javier,

1. getArray() method will return the null value and getArray()[index=2]++ throws the Null pointer exception. You handled the exception, so the program won't terminate and it prints the index value as 2 .

2. getArray()[index=2]++;

Here you are accessing the interger array index value and increment the value by 1. If you terminate the getArray();, then how will you access the array index. Then the compiler will throw the error.

I would recommend you to read the basics of Array.
9 years ago

but there's a problem in next program,
please can you tell whats wrong with this one

public class MyFirstClass{
public static void main(String[] args){
System.out.println(“hello World”);
int x = 10;
int y = 20;
int c = x + y;
System.out.println(c );
}
}

cause when m running it,it says

C:\Users\akashy\java\src>javac MyFirstClass.java
MyFirstClass.java:3: illegal character: \8220
System.out.println(ôhello Worldö);
^
MyFirstClass.java:3: ';' expected
System.out.println(ôhello Worldö);
^
MyFirstClass.java:3: illegal character: \8221
System.out.println(ôhello Worldö);
^
MyFirstClass.java:3: not a statement
System.out.println(ôhello Worldö);
^
4 errors

now whats wrong with this one



<Thanigai arasu>
I hope you might copy pasted this code, the quotes "" you have used in this program will have the different ascii value. so the java compiler treat this as a ill-legal character. As a beginner, avoid copy paste.

</Thanigai arasu>
9 years ago
The final is the powerful keywords in java for class design.

While design your application, The class that you don't want to inherit then define as the final class. Mostly the Util classes should be the final class. String is one of the final class in java. If you want the method should not be over-ridden, then the method should be final. If you want to declare the variable to treat like constant, then it should be final variable.

Static keyword is used for class level implementation of Variables/Methods and not for Object level. The intention here is to access the variable using the directly the Class Name. Same time, if you mentioned object.methodName() or object.variableName for calling the static method then also internally it will consider it as ClassName.methodeName().
9 years ago