References/Links: http://pasted.co/e2c5f8f3
Chapters
Hello everybody and welcome to my tutorial. In this tutorial, we will study java reserved keywords, Source file declaration rules, basic program structure of a source file and compiling our source code. If you're ready then let's get started!
Java program can be written as a standalone application that can be run on any computer with JVM, an applet that run from a web browser and a servlet that run from a web server to generate dynamic web contents. java application is a popular program in java because most general tools/application that is needed in the computing world, can be done by creating a simple java application and java application is a good starting point for beginners.
First of all let's discuss the java reserved keywords, reserved keywords have a predefined meaning in the language. Because of this, we programmers cannot use keywords as names for variables, methods, classes or as any other identifier. Most IDE and some text editor use syntax highlighting to display keywords in a different color. Here are some reserved keywords: for, while, case, switch, class, instanceof, implements, extends, etc.
Now, let's study the source file declaration rules in java. Remember these rules because we're gonna follow some of it later.
1.) There can be only one public top-level class per source file.
2.) A source file can have multiple non-public classes.
3.) Top-level class name and source file name must be the same.
4.) package statement must be the first statement in the source file, If the class of the source file is defined in the package(comments are allowed above the package statement).
5.) There must be only one package statement in a source file, but multiple import statements are allowed as many as you desire.
6.) import statements must come after the package statement (or at the start of the source file is there is no package statement) and must come before the top-level class declaration.
7.) Package and import statements will be applied to all classes that is present in the source file, whether you want it or not.
You might ask yourself "what is statement, import and public? i have no idea what this guy is talking about." Don't worry if all of the things that we discussed don't make sense to you, it will all make sense to you as we progress further, so just be patient and accept how things are done for now.
And now we can start coding, Remember the folder that we created? Well open that folder now and find the java source file there, then open it with your preferred text editor, mine is atom text editor. I hope you remember the java declaration rules that i discussed earlier because we're gonna apply those rules here. Remember I said that the folder where our source file reside will be the package for our source file? but how do we tell that to the java compiler? Well, the solution for that is to write a package statement.
Chapters
Introduction
Hello everybody and welcome to my tutorial. In this tutorial, we will study java reserved keywords, Source file declaration rules, basic program structure of a source file and compiling our source code. If you're ready then let's get started!
Java program can be written as a standalone application that can be run on any computer with JVM, an applet that run from a web browser and a servlet that run from a web server to generate dynamic web contents. java application is a popular program in java because most general tools/application that is needed in the computing world, can be done by creating a simple java application and java application is a good starting point for beginners.
Java Reserved Keywords
First of all let's discuss the java reserved keywords, reserved keywords have a predefined meaning in the language. Because of this, we programmers cannot use keywords as names for variables, methods, classes or as any other identifier. Most IDE and some text editor use syntax highlighting to display keywords in a different color. Here are some reserved keywords: for, while, case, switch, class, instanceof, implements, extends, etc.
Java Source File Declaration and Fundamental Code Structure
Now, let's study the source file declaration rules in java. Remember these rules because we're gonna follow some of it later.
1.) There can be only one public top-level class per source file.
2.) A source file can have multiple non-public classes.
3.) Top-level class name and source file name must be the same.
4.) package statement must be the first statement in the source file, If the class of the source file is defined in the package(comments are allowed above the package statement).
5.) There must be only one package statement in a source file, but multiple import statements are allowed as many as you desire.
6.) import statements must come after the package statement (or at the start of the source file is there is no package statement) and must come before the top-level class declaration.
7.) Package and import statements will be applied to all classes that is present in the source file, whether you want it or not.
You might ask yourself "what is statement, import and public? i have no idea what this guy is talking about." Don't worry if all of the things that we discussed don't make sense to you, it will all make sense to you as we progress further, so just be patient and accept how things are done for now.
Coding Our First Java Program
And now we can start coding, Remember the folder that we created? Well open that folder now and find the java source file there, then open it with your preferred text editor, mine is atom text editor. I hope you remember the java declaration rules that i discussed earlier because we're gonna apply those rules here. Remember I said that the folder where our source file reside will be the package for our source file? but how do we tell that to the java compiler? Well, the solution for that is to write a package statement.
Package Declaration