UNIT 3 (C)
UNIT 3 (C)
Unit 3(c)
Final keyword
• https://www.geeksforgeeks.org/final-keyword
-java
/
Static keyword
• To create a static member(block, variable,
method, nested class), precede its declaration
with the keyword static.
• When a member is declared static, it can be
accessed before any objects of its class are
created, and without reference to any object.
• For example, in below java program, we are
accessing static method m1() without creating
any object of Test class.
Static methods
Static variable
• The static variable can be used to refer to the
common property of all objects (which is not
unique for each object), for example, the
company name of employees, college name of
students, etc.
• The static variable gets memory only once in
the class area at the time of class loading.
• It makes your program memory efficient (i.e.,
it saves memory).
Static variable
Command line arguments
• The command line argument is the argument passed to a
program at the time when you run it. To access the
command-line argument inside a java program is quite easy,
they are stored as string in String array passed to the args
parameter of main() method.
• If we run a Java Program by writing the command “java
Hello Geeks At GeeksForGeeks” where the name of the
class is “Hello”, then it will run upto Hello. It is command
upto “Hello” and after that i.e “Geeks At GeeksForGeeks”,
these are command line arguments.
• When command line arguments are supplied to JVM, JVM
wraps these and supply to args[]. It can be confirmed that
they are actually wrapped up in args array by checking the
length of args using args.length