SlideShare a Scribd company logo
1
Java Array
Handled By
Dr.T.Abirami
Associate Professor
Department of IT
Kongu Engineering College
Perundurai
Array
 used to store multiple values in a single
variable, instead of declaring separate
variables for each value.
 To declare an array, define the variable type
with square brackets []
 an array is a collection of similar types of
data.
 For example, if we want to store the names
of 100 people then we can create an array
of the string type that can store 100 names.
2
Types of Array in java
There are two types of array.
 Single Dimensional Array
 Multidimensional Array
3
Define an Array Variable in Java
Syntax:
datatype[] identifier; //preferred way
or
datatype identifier[];
Example:
char refVar[];
char[] refVar;
int[] refVar;
short[] refVar;
long[] refVar; 4
Initialize an array
 By using new operator array can be initialized
dataType[] arrayRefVar = new dataType[arraySize];
int[] age = new int[5]; //5 is the size of array.
int age[5]={22,25,30,32,35};
5
 String[] cars = {"Volvo", "BMW", "Ford",
"Mazda"};
 int[] myNum = {10, 20, 30, 40};
6
Access the Elements of an Array
 access an array element by referring to
the index number.
String[] cars = {"Volvo", "BMW", "Ford",
"Mazda"};
System.out.println(cars[0]);
// Outputs Volvo
7
Array Length
String[] cars = {"Volvo", "BMW", "Ford",
"Mazda"};
System.out.println(cars.length);
// Outputs 4
8
Loop Through an Array
 the array elements with the for loop, and
use the length property to specify how
many times the loop should run.
String[] cars = {"Volvo", "BMW", "Ford",
"Mazda"};
for (int i = 0; i < 4; i++)
{
System.out.println(cars[i]);
}
9
//Java Program to illustrate the use of declaration, instantiation
//and initialization of Java array in a single line
class Testarray1{
public static void main(String args[]){
int a[]={33,3,4,5};//declaration, instantiation and initialization
//printing array
for(int i=0;i<a.length;i++)//length is the property of array
System.out.println(a[i]);
}}
10
Multidimensional Arrays
 containing one or more arrays.
 add each array within its own set of curly
braces:
dataType[][] arrayRefVar; (or)
dataType [][]arrayRefVar; (or)
dataType arrayRefVar[][]; (or)
dataType []arrayRefVar[];
11
int[][] arr=new int[3][3];
//3 row and 3 column
arr[0][0]=1;
arr[0][1]=2;
arr[0][2]=3;
arr[1][0]=4;
arr[1][1]=5;
arr[1][2]=6;
arr[2][0]=7;
arr[2][1]=8;
arr[2][2]=9;
12
class Testarray3{
public static void main(String args[]){
//declaring and initializing 2D array
int arr[][]={{1,2,3},{2,4,5},{4,4,5}};
//printing 2D array
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
System.out.print(arr[i][j]+" ");
}
System.out.println();
}
}} 13
int[][] myNumbers = { {1, 2, 3, 4}, {5, 6, 7} };
int x = myNumbers[1][2];
System.out.println(x); // Outputs 7
14
class Testarray5{
public static void main(String args[]){
//creating two matrices
int a[][]={{1,3,4},{3,4,5}};
int b[][]={{1,3,4},{3,4,5}};
//creating another matrix to store the sum of two matrices
int c[][]=new int[2][3];
//adding and printing addition of 2 matrices
for(int i=0;i<2;i++){
for(int j=0;j<3;j++){
c[i][j]=a[i][j]+b[i][j];
System.out.print(c[i][j]+" ");
}
System.out.println();//new line
}
}}
15
addition of two matrices in Java
import java.util.Scanner;
class ExString
{
public static void main(String ar[])
{
int[] a=new int[2];
Scanner sc=new Scanner(System.in);
System.out.println("Enter the elements");
for(int i=0;i<2;i++)
{
a[i]=sc.nextInt();
}
System.out.println("Print the elements");
for(int i=0;i<2;i++)
{
System.out.println(a[i]);
}
}
}
16
import java.util.Scanner;
class ExString
{
public static void main(String ar[])
{
int[][] a=new int[2][2];
Scanner sc=new Scanner(System.in);
System.out.println("Enter the elements");
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
a[i][j]=sc.nextInt();
}
}
System.out.println("Print the elements");
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
System.out.println(a[i][j]);
}
}
}
}
17
Jagged Array in Java
 arrays are of different size
 it is an array of arrays with different
number of columns.
Example
class Main
{
public static void main(String[] args)
{
// Declare a 2-D array with 3 rows
int myarray[][] = new int[3][];
// define and initialize jagged array
myarray[0] = new int[]{1,2,3};
myarray[1] = new int[]{4,5};
myarray[2] = new int[]{6,7,8,9,10};
// display the jagged array
System.out.println("Two dimensional Jagged Array:");
for (int i=0; i<myarray.length; i++)
{
for (int j=0; j<myarray[i].length; j++)
System.out.print(myarray[i][j] + " ");
System.out.println();
}
}
}
19
declaring a 2D array with different
columns
int arr[][] = new int[3][];
arr[0] = new int[3];
arr[1] = new int[4];
arr[2] = new int[2];
 int myarray[][] = new int[][]{
 new int[] { 1, 2, 3 };
 new int[] { 4, 5, 6, 7 };
 new int[] { 8, 9 };
 };
//initializing a jagged array
int count = 0;
for (int i=0; i<arr.length; i++)
for(int j=0; j<arr[i].length; j++)
arr[i][j] = count++;
differences between print() and
println().
22
Sr.
No.
Key print() println()
1
Implementation print method is implemented
as it prints the text on the
console and the cursor remains
at the end of the text at the
console.
On the other hand, println method
is implemented as prints the text
on the console and the cursor
remains at the start of the next line
at the console and the next
printing takes place from next
line.
2
Nature The prints method simply print
text on the console and does
not add any new line.
While println adds new line after
print text on console.
3
Arguments print method works only with
input parameter passed
otherwise in case no argument
is passed it throws syntax
exception.
println method works both with
and without parameter and do
not throw any type of exception.
import java.io.*;
class JavaTester {
public static void main(String[] args){
System.out.print("Hello");
System.out.print("World");
}
}
23
Output
HelloWorld
import java.io.*;
class JavaTester {
public static void main(String[] args)
{
System.out.println("Hello");
System.out.println("World");
}
}
24
Output
Hello
World

More Related Content

What's hot (20)

PPTX
Arrays in java
bhavesh prakash
 
PPTX
Array in c#
Prem Kumar Badri
 
PPTX
Arrays in java language
Hareem Naz
 
PDF
Lecture 6
Debasish Pratihari
 
PDF
Arrays in Java | Edureka
Edureka!
 
PDF
Array and Collections in c#
Umar Farooq
 
PDF
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
DOCX
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
PPT
Array in Java
Shehrevar Davierwala
 
PDF
An Introduction to Programming in Java: Arrays
Martin Chapman
 
PPT
Csharp4 arrays and_tuples
Abed Bukhari
 
PPT
Java: Introduction to Arrays
Tareq Hasan
 
PPT
07slide
Dorothea Chaffin
 
PPTX
Chap1 array
raksharao
 
PPTX
Computer programming 2 Lesson 13
MLG College of Learning, Inc
 
PDF
Java chapter 6 - Arrays -syntax and use
Mukesh Tekwani
 
PPTX
Arrays in Java
Abhilash Nair
 
PDF
Java Arrays
OXUS 20
 
PPTX
Java arrays
Maneesha Caldera
 
PPTX
Arrays basics
sudhirvegad
 
Arrays in java
bhavesh prakash
 
Array in c#
Prem Kumar Badri
 
Arrays in java language
Hareem Naz
 
Arrays in Java | Edureka
Edureka!
 
Array and Collections in c#
Umar Farooq
 
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
Array in Java
Shehrevar Davierwala
 
An Introduction to Programming in Java: Arrays
Martin Chapman
 
Csharp4 arrays and_tuples
Abed Bukhari
 
Java: Introduction to Arrays
Tareq Hasan
 
Chap1 array
raksharao
 
Computer programming 2 Lesson 13
MLG College of Learning, Inc
 
Java chapter 6 - Arrays -syntax and use
Mukesh Tekwani
 
Arrays in Java
Abhilash Nair
 
Java Arrays
OXUS 20
 
Java arrays
Maneesha Caldera
 
Arrays basics
sudhirvegad
 

Similar to Array (20)

PPTX
OOPs with java
AAKANKSHA JAIN
 
PDF
Arrays in Java
Naz Abdalla
 
PPTX
Java Programming
Nanthini Kempaiyan
 
PPTX
Lecture 7 arrays
manish kumar
 
PPTX
Java Array String
Manish Tiwari
 
PPTX
Array.pptx
ssuser8698eb
 
PPTX
ARRAYS.pptx
akila m
 
PPTX
Arrays in programming
TaseerRao
 
PPSX
dizital pods session 6-arrays.ppsx
VijayKumarLokanadam
 
PPTX
dizital pods session 6-arrays.pptx
VijayKumarLokanadam
 
PPTX
6_Array.pptx
shafat6712
 
PPTX
Arrays in java.pptx
Nagaraju Pamarthi
 
PDF
Object Oriented Programming - 5.1. Array
AndiNurkholis1
 
PPT
L10 array
teach4uin
 
PPT
Comp102 lec 8
Fraz Bakhsh
 
PDF
Learn Java Part 9
Gurpreet singh
 
PPT
Md05 arrays
Rakesh Madugula
 
PPTX
Arrays in Data Structure and Algorithm
KristinaBorooah
 
PPTX
Chapter6 (4) (1).pptx plog fix down more
mohammadalali41
 
PPT
17-Arrays en java presentación documento
DiegoGamboaSafla
 
OOPs with java
AAKANKSHA JAIN
 
Arrays in Java
Naz Abdalla
 
Java Programming
Nanthini Kempaiyan
 
Lecture 7 arrays
manish kumar
 
Java Array String
Manish Tiwari
 
Array.pptx
ssuser8698eb
 
ARRAYS.pptx
akila m
 
Arrays in programming
TaseerRao
 
dizital pods session 6-arrays.ppsx
VijayKumarLokanadam
 
dizital pods session 6-arrays.pptx
VijayKumarLokanadam
 
6_Array.pptx
shafat6712
 
Arrays in java.pptx
Nagaraju Pamarthi
 
Object Oriented Programming - 5.1. Array
AndiNurkholis1
 
L10 array
teach4uin
 
Comp102 lec 8
Fraz Bakhsh
 
Learn Java Part 9
Gurpreet singh
 
Md05 arrays
Rakesh Madugula
 
Arrays in Data Structure and Algorithm
KristinaBorooah
 
Chapter6 (4) (1).pptx plog fix down more
mohammadalali41
 
17-Arrays en java presentación documento
DiegoGamboaSafla
 
Ad

More from Kongu Engineering College, Perundurai, Erode (20)

PPTX
Event Handling -_GET _ POSTimplementation.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Introduction to Generative AI refers to a subset of artificial intelligence
Kongu Engineering College, Perundurai, Erode
 
PPTX
Introduction to Microsoft Power BI is a business analytics service
Kongu Engineering College, Perundurai, Erode
 
PPTX
Connect to NoSQL Database (MongoDB) using Node JS & Connect Node.js with NoSQ...
Kongu Engineering College, Perundurai, Erode
 
PPTX
concept of server-side JavaScript / JS Framework: NODEJS
Kongu Engineering College, Perundurai, Erode
 
PPTX
Node.js web-based Example :Run a local server in order to start using node.js...
Kongu Engineering College, Perundurai, Erode
 
PPT
Concepts of Satellite Communication and types and its applications
Kongu Engineering College, Perundurai, Erode
 
PPT
Concepts of Mobile Communication Wireless LANs, Bluetooth , HiperLAN
Kongu Engineering College, Perundurai, Erode
 
PPTX
Web Technology Introduction framework.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Computer Network - Unicast Routing Distance vector Link state vector
Kongu Engineering College, Perundurai, Erode
 
PPT
Android SQLite database oriented application development
Kongu Engineering College, Perundurai, Erode
 
PPT
Android Application Development Programming
Kongu Engineering College, Perundurai, Erode
 
PPTX
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
PPTX
A REST API (also called a RESTful API or RESTful web API) is an application p...
Kongu Engineering College, Perundurai, Erode
 
PPTX
SOA and Monolith Architecture - Micro Services.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Connect to NoSQL Database using Node JS.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Bootstarp installation.pptx
Kongu Engineering College, Perundurai, Erode
 
Event Handling -_GET _ POSTimplementation.pptx
Kongu Engineering College, Perundurai, Erode
 
Introduction to Generative AI refers to a subset of artificial intelligence
Kongu Engineering College, Perundurai, Erode
 
Introduction to Microsoft Power BI is a business analytics service
Kongu Engineering College, Perundurai, Erode
 
Connect to NoSQL Database (MongoDB) using Node JS & Connect Node.js with NoSQ...
Kongu Engineering College, Perundurai, Erode
 
concept of server-side JavaScript / JS Framework: NODEJS
Kongu Engineering College, Perundurai, Erode
 
Node.js web-based Example :Run a local server in order to start using node.js...
Kongu Engineering College, Perundurai, Erode
 
Concepts of Satellite Communication and types and its applications
Kongu Engineering College, Perundurai, Erode
 
Concepts of Mobile Communication Wireless LANs, Bluetooth , HiperLAN
Kongu Engineering College, Perundurai, Erode
 
Web Technology Introduction framework.pptx
Kongu Engineering College, Perundurai, Erode
 
Computer Network - Unicast Routing Distance vector Link state vector
Kongu Engineering College, Perundurai, Erode
 
Android SQLite database oriented application development
Kongu Engineering College, Perundurai, Erode
 
Android Application Development Programming
Kongu Engineering College, Perundurai, Erode
 
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
A REST API (also called a RESTful API or RESTful web API) is an application p...
Kongu Engineering College, Perundurai, Erode
 
SOA and Monolith Architecture - Micro Services.pptx
Kongu Engineering College, Perundurai, Erode
 
Connect to NoSQL Database using Node JS.pptx
Kongu Engineering College, Perundurai, Erode
 
Ad

Recently uploaded (20)

PDF
Web Technologies - Chapter 3 of Front end path.pdf
reemaaliasker
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PPTX
Precedence and Associativity in C prog. language
Mahendra Dheer
 
PPTX
sunil mishra pptmmmmmmmmmmmmmmmmmmmmmmmmm
singhamit111
 
PDF
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
PDF
Zero Carbon Building Performance standard
BassemOsman1
 
PDF
勉強会資料_An Image is Worth More Than 16x16 Patches
NABLAS株式会社
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PPTX
Fluid statistics and Numerical on pascal law
Ravindra Kolhe
 
PDF
CFM 56-7B - Engine General Familiarization. PDF
Gianluca Foro
 
PDF
7.2 Physical Layer.pdf123456789101112123
MinaMolky
 
PPTX
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
PDF
Geothermal Heat Pump ppt-SHRESTH S KOKNE
SHRESTHKOKNE
 
PPTX
00-ClimateChangeImpactCIAProcess_PPTon23.12.2024-ByDr.VijayanGurumurthyIyer1....
praz3
 
PDF
The Complete Guide to the Role of the Fourth Engineer On Ships
Mahmoud Moghtaderi
 
PDF
Non Text Magic Studio Magic Design for Presentations L&P.pdf
rajpal7872
 
PPTX
Unit II: Meteorology of Air Pollution and Control Engineering:
sundharamm
 
PPTX
Online Cab Booking and Management System.pptx
diptipaneri80
 
PPTX
Unit 2 Theodolite and Tachometric surveying p.pptx
satheeshkumarcivil
 
PPTX
ETP Presentation(1000m3 Small ETP For Power Plant and industry
MD Azharul Islam
 
Web Technologies - Chapter 3 of Front end path.pdf
reemaaliasker
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
Precedence and Associativity in C prog. language
Mahendra Dheer
 
sunil mishra pptmmmmmmmmmmmmmmmmmmmmmmmmm
singhamit111
 
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
Zero Carbon Building Performance standard
BassemOsman1
 
勉強会資料_An Image is Worth More Than 16x16 Patches
NABLAS株式会社
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
Fluid statistics and Numerical on pascal law
Ravindra Kolhe
 
CFM 56-7B - Engine General Familiarization. PDF
Gianluca Foro
 
7.2 Physical Layer.pdf123456789101112123
MinaMolky
 
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
Geothermal Heat Pump ppt-SHRESTH S KOKNE
SHRESTHKOKNE
 
00-ClimateChangeImpactCIAProcess_PPTon23.12.2024-ByDr.VijayanGurumurthyIyer1....
praz3
 
The Complete Guide to the Role of the Fourth Engineer On Ships
Mahmoud Moghtaderi
 
Non Text Magic Studio Magic Design for Presentations L&P.pdf
rajpal7872
 
Unit II: Meteorology of Air Pollution and Control Engineering:
sundharamm
 
Online Cab Booking and Management System.pptx
diptipaneri80
 
Unit 2 Theodolite and Tachometric surveying p.pptx
satheeshkumarcivil
 
ETP Presentation(1000m3 Small ETP For Power Plant and industry
MD Azharul Islam
 

Array

  • 1. 1 Java Array Handled By Dr.T.Abirami Associate Professor Department of IT Kongu Engineering College Perundurai
  • 2. Array  used to store multiple values in a single variable, instead of declaring separate variables for each value.  To declare an array, define the variable type with square brackets []  an array is a collection of similar types of data.  For example, if we want to store the names of 100 people then we can create an array of the string type that can store 100 names. 2
  • 3. Types of Array in java There are two types of array.  Single Dimensional Array  Multidimensional Array 3
  • 4. Define an Array Variable in Java Syntax: datatype[] identifier; //preferred way or datatype identifier[]; Example: char refVar[]; char[] refVar; int[] refVar; short[] refVar; long[] refVar; 4
  • 5. Initialize an array  By using new operator array can be initialized dataType[] arrayRefVar = new dataType[arraySize]; int[] age = new int[5]; //5 is the size of array. int age[5]={22,25,30,32,35}; 5
  • 6.  String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};  int[] myNum = {10, 20, 30, 40}; 6
  • 7. Access the Elements of an Array  access an array element by referring to the index number. String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; System.out.println(cars[0]); // Outputs Volvo 7
  • 8. Array Length String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; System.out.println(cars.length); // Outputs 4 8
  • 9. Loop Through an Array  the array elements with the for loop, and use the length property to specify how many times the loop should run. String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; for (int i = 0; i < 4; i++) { System.out.println(cars[i]); } 9
  • 10. //Java Program to illustrate the use of declaration, instantiation //and initialization of Java array in a single line class Testarray1{ public static void main(String args[]){ int a[]={33,3,4,5};//declaration, instantiation and initialization //printing array for(int i=0;i<a.length;i++)//length is the property of array System.out.println(a[i]); }} 10
  • 11. Multidimensional Arrays  containing one or more arrays.  add each array within its own set of curly braces: dataType[][] arrayRefVar; (or) dataType [][]arrayRefVar; (or) dataType arrayRefVar[][]; (or) dataType []arrayRefVar[]; 11
  • 12. int[][] arr=new int[3][3]; //3 row and 3 column arr[0][0]=1; arr[0][1]=2; arr[0][2]=3; arr[1][0]=4; arr[1][1]=5; arr[1][2]=6; arr[2][0]=7; arr[2][1]=8; arr[2][2]=9; 12
  • 13. class Testarray3{ public static void main(String args[]){ //declaring and initializing 2D array int arr[][]={{1,2,3},{2,4,5},{4,4,5}}; //printing 2D array for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ System.out.print(arr[i][j]+" "); } System.out.println(); } }} 13
  • 14. int[][] myNumbers = { {1, 2, 3, 4}, {5, 6, 7} }; int x = myNumbers[1][2]; System.out.println(x); // Outputs 7 14
  • 15. class Testarray5{ public static void main(String args[]){ //creating two matrices int a[][]={{1,3,4},{3,4,5}}; int b[][]={{1,3,4},{3,4,5}}; //creating another matrix to store the sum of two matrices int c[][]=new int[2][3]; //adding and printing addition of 2 matrices for(int i=0;i<2;i++){ for(int j=0;j<3;j++){ c[i][j]=a[i][j]+b[i][j]; System.out.print(c[i][j]+" "); } System.out.println();//new line } }} 15 addition of two matrices in Java
  • 16. import java.util.Scanner; class ExString { public static void main(String ar[]) { int[] a=new int[2]; Scanner sc=new Scanner(System.in); System.out.println("Enter the elements"); for(int i=0;i<2;i++) { a[i]=sc.nextInt(); } System.out.println("Print the elements"); for(int i=0;i<2;i++) { System.out.println(a[i]); } } } 16
  • 17. import java.util.Scanner; class ExString { public static void main(String ar[]) { int[][] a=new int[2][2]; Scanner sc=new Scanner(System.in); System.out.println("Enter the elements"); for(int i=0;i<2;i++) { for(int j=0;j<2;j++) { a[i][j]=sc.nextInt(); } } System.out.println("Print the elements"); for(int i=0;i<2;i++) { for(int j=0;j<2;j++) { System.out.println(a[i][j]); } } } } 17
  • 18. Jagged Array in Java  arrays are of different size  it is an array of arrays with different number of columns.
  • 19. Example class Main { public static void main(String[] args) { // Declare a 2-D array with 3 rows int myarray[][] = new int[3][]; // define and initialize jagged array myarray[0] = new int[]{1,2,3}; myarray[1] = new int[]{4,5}; myarray[2] = new int[]{6,7,8,9,10}; // display the jagged array System.out.println("Two dimensional Jagged Array:"); for (int i=0; i<myarray.length; i++) { for (int j=0; j<myarray[i].length; j++) System.out.print(myarray[i][j] + " "); System.out.println(); } } } 19
  • 20. declaring a 2D array with different columns int arr[][] = new int[3][]; arr[0] = new int[3]; arr[1] = new int[4]; arr[2] = new int[2];  int myarray[][] = new int[][]{  new int[] { 1, 2, 3 };  new int[] { 4, 5, 6, 7 };  new int[] { 8, 9 };  };
  • 21. //initializing a jagged array int count = 0; for (int i=0; i<arr.length; i++) for(int j=0; j<arr[i].length; j++) arr[i][j] = count++;
  • 22. differences between print() and println(). 22 Sr. No. Key print() println() 1 Implementation print method is implemented as it prints the text on the console and the cursor remains at the end of the text at the console. On the other hand, println method is implemented as prints the text on the console and the cursor remains at the start of the next line at the console and the next printing takes place from next line. 2 Nature The prints method simply print text on the console and does not add any new line. While println adds new line after print text on console. 3 Arguments print method works only with input parameter passed otherwise in case no argument is passed it throws syntax exception. println method works both with and without parameter and do not throw any type of exception.
  • 23. import java.io.*; class JavaTester { public static void main(String[] args){ System.out.print("Hello"); System.out.print("World"); } } 23 Output HelloWorld
  • 24. import java.io.*; class JavaTester { public static void main(String[] args) { System.out.println("Hello"); System.out.println("World"); } } 24 Output Hello World