Created
December 30, 2021 12:40
-
-
Save arsalankhan994/9521ec87c28a706bd031fc6ded979196 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class KeywordsJava { | |
public static void main(String[] args) { | |
/* | |
using final, to assign value only one time | |
*/ | |
final String nonChangeableVariable = "Erselan Khan"; | |
nonChangeableVariable = "Arsalan Khan"; | |
/* | |
Accessing object bound method | |
*/ | |
SomeClass someClass = new SomeClass(); | |
someClass.objectBoundMethod(); | |
/* | |
using static keyword, for accessing class bound method | |
*/ | |
SomeClass.classBoundMethod(); | |
try { | |
String name = null; | |
name.toString(); // this line will throw null pointer exception | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} finally { | |
System.out.println("finally called"); | |
} | |
} | |
} | |
class SomeClass { | |
static void classBoundMethod() { | |
System.out.println("This is class bound method"); | |
} | |
void objectBoundMethod() { | |
System.out.println("This is object bound method"); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment