Page 111 - 2617_JSSPS_C-7
P. 111
Program 11: Write a program to print Touchpad 10 times.
1 public class ForLoop
2 {
3 public static void main(String args[])
4 {
5 int i;
6 for(i=1; i<=10; i++)
7 {
8 System.out.println("Touchpad");
9 }
10 }
11 }
The preceding program prints the word ‘Touchpad’ ten times.
Factbot
The for-each loop in Java is a simpler way to iterate over elements of an array or a collection, like an ArrayList.
It is also known as an enhanced for loop. The syntax of for-each loop is as follows:
for (dataType item : collection)
{
// body of loop
}
OBJECT-ORIENTED PROGRAMMING
Object-Oriented programming is another way of programming. It follows a Bottom-Up approach and
emphasises more on data rather than functions.
It splits the program into a number of entities, known as objects. It increases the ability to deal with
complex software problems—particularly for developing and maintaining large real-life applications
and data arrangements.
Using this technique of writing source code makes it easy to create different objects from a common
structure. This common structure is usually called a blueprint or class and the objects that are created
are called instances.
Java, C++, C#, Python are some commonly known Object-Oriented Programming languages.
Java Programming 109

