Today I'll take a stab at explaining Java programming language keywords to you all.
As the title suggests, this explanation is aimed towards total newbies to Java, and probably also suitable for those having trouble understanding Java objects, especially to non-English speakers.
What made me start this series is simply because I had the same problem when i started programming, and I happen to start with Java, and not Python or C or other traditionally introductory language. At the time, there were a lot of explanations online, but because of my limited vocabulary of the English language, it took me longer to understand simple stuff.
I hope this series will help some understand Java faster.
variable
a name given to an object
As a non-native speaker, this was really confusing to me. It is actually very easy. Variables are like giving names to your cats. They all are cats, but with different names.
namespace
a name or path to specify location/collection of items
Yes, I realize namespace is not Java-exclusive, but anyone who wishes to start programming should know what a namespace is. A simple way to think of a namespace is it is sort of the drive letter in your computer. If you have C drive and D drive, you could also say you have C namespace and D namespace.
package
specifies what location/collection the current file is in
If I put
package com.asrihashim.main
it means that the file is in folder com/asrihashim/main where com is a folder at my project's root
import
takes the specified file in a different folder to be used in current file
Since every
.java
file/class can call methods/functions in other .java
file/class, import makes sure it knows where the Java file is located.It also makes sure which class in Java SDK the file needs.
public
specifies the object to be accessible by anyone
When something is specified as public, it can be called by any Java class, no matter where it is called from
protected
specifies the object to be accessible by its subclass(es) only
Protected objects are only accessible by itself, and any subclass(es) extending the class it is in
private
specifies the object to be accessible by itself only
private objects are only accessible or can be called by itself, or simply in the class where it sits in only
Continue reading Part 2 here.
No comments:
Post a Comment