Download Java 1

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Java 1
LAB 1
DR MOHAMED MADDEH
Integrated Development Environment
(IDE)
Software that consolidates the basic tools that developers need :

write (A code editor),

A compiler ,

A debugger ,

Graphical user interface (GUI).
Netbeans
Netbeans


The Computer-Aided Software Engineering (CASE): is the application of
tools, methods, and disciplines to produce and maintain an automatic
solution to a real-world problem.
CASE tools divided into:



Upper CASE tools
Lower CASE tools
Integrated CASE
NetBeans IDE
JRE JDK

JRE is an acronym for Java Runtime Environment. It is used to provide
runtime environment. It is the implementation of JVM.

JDK is an acronym for Java Development Kit. It physically exists.It contains
JRE + development tools.
JDK
Creating new project
Creating new project
Creating new project
Creating new project
Building and exectuting
Creating new project
Hammer button or build
The green button for run
Building and exectuting
The ability to work in one single
environment
Netbeans will put
all the power in a
single
environment, so
you can edit
multiple files at
once, compile, fix
your errors, and
run and test your
program.
Syntax highlighting

Netbeans will
highlight all java
keywords such as
"if", "for" and "int". It
will also make your
comments, strings,
and methods
different colors
Automatic braces, and quotes and
Auto-complete

Whenever you press
"." after an instance
of a class, you will
get a menu with all
the methods and
public members that
you can call on that
particular instance.
Syntax error detection

Netbeans shows
you if you have any
syntax errors
BEFORE you
compile, so you
can fix them to
save time.
Netbeans may
even give you
suggestions about
how to fix a
particular error.
Basic Syntax
About Java programs, it is very important to keep in mind the following points.

Case Sensitivity − Java is case sensitive, which means identifier
Hello and hello would have different meaning in Java.

Class Names − For all class names the first letter should be in Upper Case.
Example: class MyFirstJavaClass

Method Names − All method names should start with a Lower Case letter. If
several words are used to form the name of the method, then each inner
word's first letter should be in Upper Case.
Example: public void myMethodName()
Basic Syntax

Program File Name − Name of the program file should exactly match the
class name.
When saving the file, you should save it using the class name (Remember
Java is case sensitive)
Example: Assume 'MyFirstJavaProgram' is the class name. Then the file should
be saved as 'MyFirstJavaProgram.java'

public static void main(String args[]) − Java program processing starts from
the main() method which is a mandatory part of every Java program.
Example 1
package javaapplication2;
public class JavaApplication2
{
public static void main(String[] args)
{
System.out.println(" It s my first application");
}
}
Example 2
package javaapplication2;
import java.util.Scanner;
public class JavaApplication2 {
public static void main(String[] args) {
int discount; int price; int amountTopay;
System.out.println(" Please Give me the discount amount");
Scanner sc1 = new Scanner(System.in);
discount = sc1.nextInt();
System.out.println(" Please Give me the price"); Scanner sc2 = new Scanner(System.in);
price = sc2.nextInt();
amountTopay = price - discount;
System.out.println(" The amount is : " + amountTopay );
}
}

Demo
Exercice

Write and execute a java program that display your name, age and
hobby.

http://www.acadox.com/class/37748