Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Introduction to java

Rating
-
Sold
-
Pages
9
Uploaded on
07-05-2025
Written in
2024/2025

Java is a popular object-oriented programming language, known for its stability, scalability, and security. In this chapter, we learned about the basics and features of Java

Institution
Course

Content preview

Java is a popular object-oriented programming language, known for its
stability, scalability, and security. In this chapter, we learned about the basics
and features of Java.

Hello World Program

Let’s start with the classic “Hello World” program. This is the first program
that many people write when they are learning a new programming
language:

Public class HelloWorld {

Public static void main(String[] args) {

System.out.println(“Hello, World!”);

}

}

In this example, we define a class called HelloWorld, which contains a
method called main. The main method is the entry point of the program.
When we run this program, it will print the string “Hello, World!” to the
console.

Variables and Data Types

In Java, we can define variables to store data. Here’s an example of how to
define and initialize a variable:

Int number = 42;

In this example, we define a variable called number with the data type int.
We initialize the variable to the value 42. Java supports several data types,
including:

Byte: a signed 8-bit integer (-128 to 127)

Short: a signed 16-bit integer (-32,768 to 32,767)

Int: a signed 32-bit integer (-2,147,483,648 to 2,147,483,647)

Long: a signed 64-bit integer

Float: a single-precision floating-point number

, Double: a double-precision floating-point number

Boolean: a boolean value (true or false)

Char: a Unicode character

Operators

Java supports several operators, including:



Arithmetic operators (+, -, *, /, %)

Assignment operators (=, +=, -=, *=, /=, %=)

Comparison operators (==, !=, <, >, <=, >=)

Logical operators (&&, ||, !)

Bitwise operators (&, |, ^, ~, <<, >>, >>>)

Here’s an example of using arithmetic operators:

Int a = 10;

Int b = 5;

Int result = a + b; // 15

Result = a – b; // 5

Result = a * b; // 50

Result = a / b; // 2

Result = a % b; // 0

Control Structures

Java supports several control structures, including:

If statement

If-else statement

If-else if statement

Switch statement

Loops (for, while, do-while)

Break and continue statements

Written for

Institution
Course

Document information

Uploaded on
May 7, 2025
Number of pages
9
Written in
2024/2025
Type
Class notes
Professor(s)
Jayalakshmi
Contains
All classes

Subjects

$9.39
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
divyavenkatesh

Get to know the seller

Seller avatar
divyavenkatesh SRM VALLIAMMAI ENGINEERING COLLAGE
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions