0% found this document useful (0 votes)
6 views2 pages

Java Class Notes

The document explains the 'for each' loop in Java, which is used to traverse elements in collections or arrays without needing to update loop variables manually. It provides syntax and an example of using a 'for each' loop with an integer array. Additionally, it describes 2D arrays as collections of multiple arrays in two dimensions and defines a String as a class for storing sequences of characters in the java.lang package.

Uploaded by

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

Java Class Notes

The document explains the 'for each' loop in Java, which is used to traverse elements in collections or arrays without needing to update loop variables manually. It provides syntax and an example of using a 'for each' loop with an integer array. Additionally, it describes 2D arrays as collections of multiple arrays in two dimensions and defines a String as a class for storing sequences of characters in the java.lang package.

Uploaded by

phoneixrdx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd

For each loop:

For each loop is a special loop of java it is used to


traverse the elements of collection or array
Foreach loop variables are auto undateable no need to
update the loop variables

Syntax

for( datatype variableName : Array of collection name )

{
//print
}

Example :

For ( int n : arr)


{
[Link]( n+” ”)
}

2D Array :
2D Array is a collection of multiple arrays with same
datatype in which we can store value in 2 dimensions ,
one is row and second is column.
If we want to access an element of 2D array then we
have to use indexes for rows and columns same as
matrix

String :
Technically String is a class it is sed to store or
represent collection or sequence of characters it is found
inside the [Link] package

You might also like