Learn Colors for Children | with Wooden Color Educational | super egg | Song Nursery Rhymes
-------------------------------------------
learn colors with surprise balloons and 3D cartoon cars learning videos for children by kids channel - Duration: 2:05.MAGENTA
GREEN
BLUE
RED
PURPLE
ORANGE
YELLOW
-------------------------------------------
Dinosaurs Finger Family Children Nursery Rhymes Dinosaurs Cartoon For Finger Family Song 3d Cartoons - Duration: 12:57.Dinosaurs Finger Family Children Nursery Rhymes Dinosaurs Cartoon For Finger Family Song 3d Cartoons
-------------------------------------------
Java For Beginners - Episode 02 - Writing, Compiling and Running First Java Program - Duration: 8:44.Hello, and welcome to Java course for beginners.
In previous episode we downloaded and installed Java Development Kit.
In this episode we are going to write and run our first Java program.
You can use any text editor of your choice to write a Java program. I'm going to open notepad.
Java program contains classes. We will discuss classes in detail in later episodes
but let's create one here for our first Java program.
public class HelloWorld { }
This is class name.
By convention Java class names are started with capital letters,
and if class name contains multiple words every first letter of every word is kept capital.
This makes it easier to differentiate between different words
as we can clearly read Hello and World separately.
everything that goes between these curly braces is called class body.
Since we are gonna provide some class body let's make room for it.
To run a program, there has to be some entry point.
In Java, this entry point is called main method. Let's create main method here.
public static void main (String args[]) { }
For now just remember everything as it is.
We will discuss more details in later episodes.
As you can see main method also contains the body.
And let's create room for its body as well.
It's a very good practice to indent body inside curly braces. This improves readability of program.
Let's indent class body. As this is class body,
place insertion point here and press tab, and here, and press tab.
Now, we have class and a main method.
It's time to write a statement to print Hello World.
Since this statement is going to be inside main method, it should be indented.
This time place insertion point here and press tab twice.
To print something on screen let's write
System.out.println( ) ;
Whatever information goes between these parenthesis is printed on screen.
Let's write HelloWorld!
In Java, text information is enclosed in double quotes.
Let's place double quotes, one here, and one here.
Java statements end with semicolon, so don't miss it.
We have completed writing our first program .
if you look at it, it's easy to identify different body blocks just because of indentation.
This is block of HelloWorld class, and this is block of main method.
sooner you will be writing bigger programs with more block structures,
so starting from now get used to indent your code properly.
Let's save our class file.
We can save it anywhere. I'm going to save it in C:/
I'm going to create a folder 'java'.
And class name has to be, sorry, file name has to be HelloWorld.java
because file name has to match with class name with extension java.
Let's save it, and open the location where we have saved the file.
Here it is.
It's time to run this program. But before running, a Java program needs to be compiled.
In compilation process, Java Development Kit reads our code,
and converts it into bytecode. That bytecode runs in Java Runtime Environment.
Our program, being the source of compilation, is called source code.
Now if we see on Oracle site there are different JREs available for different platforms.
so if we have a compiled program, JRE for Windows runs it on Windows operating system,
and JRE for Linux can run it on Linux.
we can compile once and run anywhere. This makes Java platform independent.
JRE is actually a container of Java libraries and Java Virtual Machine.
It's actually Java Virtual Machine which interacts with underlying platform.
If you remember from previous episode we installed java in
C:/Program Files/java/jdk-9
It's bin directory contains a lot of commands. We are interested in java and javac
javac compiles a program, and java runs it. But before running those commands
we need to add this path into environment variables.
Open environment variables and edit path variable.
Create new and paste that path. Press OK, OK, and OK again.
Now open command prompt and change directory to where our program resides.
cd c:/java
Now if we see
here is our program. Now we can issue
javac HelloWorld.java
If we go to where our program resides, we can see our program has been compiled,
and a .class file has been created. This is actually bytecode.
Now we run our program by issuing command
java HelloWorld And this time we do not give extension.
Press enter, and here we are. Our output has been printed,
If we change something in our program we have to recompile it. So let's write another line.
System.out.println("Java is awesome");
We save it, and if we don't compile it and try to run previous command
java HelloWorld our changes are not there so we have to recompile it.
javac HelloWorld.java
and now we can run it
java HelloWorld without extension,
and here we are. Our changes have been reflected.
If we make a mistake while writing a program, Java program does not compile.
Let's see how it happens. We remove this semicolon and save it.
Now we have to recompile it.
javac HelloWorld.java
Now you can see compilation is failed with one error
and the error is, on line 3, that semicolon expected here.
Java is clearly prompting us about the error in our source code.
We can see it on line 3 in HelloWorld.java and it is also pointing out where should be what.
Now we can go back and insert semicolon here, save our program.
Now come back and recompile it and now everything is fine.
Writing and maintaining Java programs in simple text editor is a very difficult task.
Luckily there are a lot of tools out there to help us, and one of them is eclipse.
In next episode we are going to configure and run Eclipse IDE. Until then goodbye
-------------------------------------------
rangoli for diwali padwa | kolam designs for diwali | simple muggulu for diwali, easy rangoli - Duration: 1:06.rangoli designs for diwali
-------------------------------------------
Learn Colors With Toilet Cow Cartoons For Children 3D Colours With Cow Dometsic Animals For Children - Duration: 12:21.Learn Colors With Toilet Cow For Children Learn Colours with Cow Domestic Animals Cartoons For Kids
Không có nhận xét nào:
Đăng nhận xét