0% found this document useful (0 votes)
3 views

JAVA

The document provides a guide for developing Java programs using JDK and NetBeans, including steps for creating a new project and writing a basic 'Hello World' program. It explains Java packages, primitive data types, basic operators, and the importance of class visibility. Additionally, it covers importing packages and using AWT and Swing for creating graphical user interfaces.

Uploaded by

marcioveloso785
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

JAVA

The document provides a guide for developing Java programs using JDK and NetBeans, including steps for creating a new project and writing a basic 'Hello World' program. It explains Java packages, primitive data types, basic operators, and the importance of class visibility. Additionally, it covers importing packages and using AWT and Swing for creating graphical user interfaces.

Uploaded by

marcioveloso785
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

JAVA

JDK is the best for developing for JAVA programs. To get it is necessary to go to Oracle website:
Oracle JDK and Netbean bundle.

Once the program is installed is necessary to go to File > New Project > Select Java and Select java
application and then press Next. > Create name for the project.

To the type of code. Inside the Package NAME > PUBLIC CLASS NAME > Public static void main
(System.out.println(“Hello World”) ; ) and then RUN

What are Java Packages


 Namespace that organises a set of related classes and interfaces
 Two types of packages: User defined and built-in
 The package declaration should be the first statement in your program

Common Java Packages

Package Name Description


Java Language (java.lang) Contains core classes for the java language
Java I/O (java.io) Provides a set of input & output streams
Java Utility (java.util) Collection of utility classes e.g. for calendar
dates
AWT Provide GUI elements the buttons, text items
AWT Image Contains classes and interfaces for managing
images
Swing Provides classes for GUI e.g. checkbones,
buttons etc.

To import the packages to the program: Import mypackage1; -Single member of the package.
Import mypackage.*; - will import all the member of the package

Primitive Data Types

Data type Description


byte Stores integers from -12 to 127. Uses 1 byte of
storage space
short Uses 2 Bytes of storage space and has a range
of 32768 to 32767
int Uses 4 bytes of storage space. Most commonly
used for storing integers
long Uses 8 bytes of storage space. Rarely used
float Uses 4 bytes of storage with a precision of
about 7 digits
double Uses 8 bytes of storage with a precision of
about 15 digits
boolean Holds two values : true or false
char Stands for characters. Stores single Unicode
character like “A”, “@”
DEFAULT VALUES
Data Type Default Value for
Fields
byte 0
short 0
int 0
long 0L
float 0.0f
double 0.0d
boolean False
char “\u0000”

Basic Operators
Operator Description Example
= Assignment Assign values int userAge = 21;
+ (Plus) Add values x=3;y=4; x+y = 7;
- (Minus) Subtracts values x=3;y=4; y-x=1;
*(Multiplication) Multiplies values x=3;y=4; x*y=12;
/ (Division) Divides values x=8;y=4; x/y=2;
% (Modulus) Returns remainder x=8;y=5; x% y=1.6;
+= (Add & Combines operators x=3;y=4; x+=2; x=x+2;
Assignment)
++ (incremental) Increases value x=3; x++; x become 4
== (equal to) Checks if values are x =3;y=3; x==y;
equal
!= (not equal to) Checks if value is not x=3; y=4; x !==y;
equal
> (Greater than) Checks if the value is x=4; y=3; x > y;
greater
< (Less than) Checks if value is less x=3; y=4; x < y;
>= (Greater than or Check if value is x=3; y=4; y >=x;
equal) greater or equal
<= (Less than or Checks if value is less x=4; y=7; x<=y;
equal) or equal

NOTE: to save and share with others it is necessary to press RUN on the top menu bar and choose
the option Clean and Build Project (Number Addiction).

A class can be either private or public, if the class is public it means that it can be accessed by
anybody, if the class is private it means it can only be accessed by other classes within the same
classes.

Terminar Excell
Terminar Java
Desenhar a noite

IMPORTING PACKAGES
Java.awt package Is used to create, it has all the
classes to create the user interfaces.
Things to be used in application,
button, scroll bar and etc.
Java.awt.FlowLayout Is used to arrange components in the direction
of flow. More like the lines of a text in
paragraph.
Java.awt.Font Allows us to specify the type of the font, size,
the family and etc.
Java.awt.Color This allows us the use different properties for
the colour
Javax.swing package Is used for java standard extensions.
Seeing is a set of program
components. It allows to create GUI
= graphical user interfaces.
Javax.swingJFrame This is a class, is a window that has a
decoration, a title, button components that
can close, and icon for the window and so on.
Javax.swing.JLabel This is the display area for text or image.

NOTE: extends JFrame = means we are extend the subclass of the class I am extending.

Alt codes for mathematical symbols

Alt 0247 = Division


Alt 0215 = Multiply
Alt 45 = Minus
Alt 43 = Plus

Char is a single letter and a string is collection of letters.

You might also like