After compilation, the .java file gets translated into the .class file called "bytecode"
Now we can run the program
(4/11)
How to run a Java program?
To run the program, type the command -
java First
We should not append the .java extension to the file name while running the program
(5/11)
Fact about a Java program
Every program in Java must be enclosed within a class.
(6/11)
Terms of a Java Program
You might have come across the following words in every Java program -
🔹public
🔹static
🔹void
🔹mean
🔹Strings args[]
But what do they mean?
Let us understand
(7/11)
Why is the main method public?
'public' keyword is an access specifier which allows the programmer to control the visibility of class members.
main() is declared as public since it must be called by code outside of its class when the program is started.
(8/11)
Why is the static keyword used?
The 'static' keyword allows main() to be called without having to instantiate a particular instance of the class.
This is necessary since main() is called by the Java interpreter before any objects are made.
(9/11)
What does 'void' mean?
The keyword 'void' simply tells the compiler that main() does not return a value.
(10/11)
What does the parameter String args[] in the main() method means?
String args[] is an array of instances of the class String which receive command-line arguments present when the program is executed.
(11/11)
How to print in Java?
To print in Java, we use -
🔹System.out.print("Hello") - without a new line
🔹System.out.println("Hello") - with a new line
After making m1 = null m1 becomes eligible for garbage collection. So when we call garbage collector the first time, Garbage Collector will call finalize() method on m1 before destroying it.
The finalize method will print "Finalise" here but in finalize method we are again referencing the same object by m which makes it no longer eligible for garbage collection. Hence the garbage collector will not destroy the object.
Confused about implementing data structures in real problems?
See some real-world examples of the Data structure "Array" today 👇
A thread 🧵
🔸A parking lot is an example of an array with each index of the array storing whether a car is present or not. Or it may be used for some other functionality.
Want to become an Android developer or start your journey with Android development but have not started yet?
Let me help you create your first Android app to kick off your Android journey.
Work with me to the end of the thread 🧵🧵
First, download Android Studio on your PC through this link and complete the setup and wait for all indexing and initial build to finish (might take time so keep patience) developer.android.com/studio
🔸Click on create new Project
🔸Select Empty Activity
🔸Click on next