---
title: "Pattern Programs ICSE Class 10 Java, Solved for 2027"
description: "Pattern programs for ICSE Class 10 Java, 2027: twelve star, number, letter and triangle patterns sorted by loop rule, each with code and real output."
canonical: https://learn.modernagecoders.com/icse-class-10-pattern-programs-java
source: src/pages/icse-class-10-pattern-programs-java.html
---
> Pattern programs for ICSE Class 10 Java, 2027: twelve star, number, letter and triangle patterns sorted by loop rule, each with code and real output.

Start here

## Courses where pattern programs are taught

The ICSE Java course in which the mini batch practises these patterns, the Class 11 and 12 Computer Science course where nested loops return in ISC programs, and Python for Teens for a student who wants to print the same shapes in a second language.

[![ICSE Computer Applications Java with BlueJ course thumbnail](/images/java-teens.webp)  The batch / ICSE CA ICSE Computer Applications, Java with BlueJ Class 9 and 10 Computer Applications in a mini batch, where a new pattern is planned and run most weeks until nested loops feel routine. Open the course →](/courses/icse-computer-applications-java-bluej-course)[![Computer Science Class 11 and 12 course thumbnail](/images/ip-cs-class-11-12.webp)  Next step / ISC Computer Science Class 11 and 12 For students going on to ISC Computer Science, where nested loops drive matrices, sorting and longer programs. Open the course →](/courses/cbse-icse-computer-science-class-11-12-python-java-complete-course)[![Python for Teens course thumbnail](/images/python-teens.webp)  Second language / Python Python for Teens For the student who likes shapes and wants to see the same loop rules written in Python after the board exam. Open the course →](/courses/python-complete-masterclass-teens)

Ans. The short version

Pattern programs for ICSE Class 10 are Java programs that print a shape, such as a star triangle, a number pyramid or a letter triangle, using nested for loops. The outer loop runs once per row; the inner loop decides how many items that row holds; an optional first inner loop prints leading spaces; and the print statement decides which character appears. Answer three questions for any pattern: how many rows, how many items in row i, and what is printed at row i, column j. Modern Age Coders teaches pattern programs live in a Tuesday and Wednesday mini batch in India, or one to one at the family's time.

Q1. How do you write any pattern program in Java?

## Nested loop patterns in Java for ICSE: the four loop rules

Every pattern is a grid printed one row at a time, so every pattern program is an outer loop for the rows with one or two inner loops inside. What changes from shape to shape is only the limit of the inner loop, whether spaces come first, and what gets printed.

| Rule | The question it answers | Where it lives in the code | Typical form |
| --- | --- | --- | --- |
| Rows | How many lines does the shape have? | The outer loop, ending with `System.out.println()` | `for (i = 1; i <= n; i++)` |
| Columns | How many items does row i hold? | The limit of the inner loop, written in terms of i | `j <= i`, `j <= n - i + 1`, `j <= 2 * i - 1` |
| Spaces | Does row i start further to the right? | A separate inner loop placed before the items | `for (s = 1; s <= n - i; s++)` |
| Characters | What is printed at row i, column j? | The argument of `System.out.print` | `"*"`, `j`, `i`, `(i + j) % 2`, `(char) ('A' + j - 1)` |

### The three questions, in order

1. **Count the rows.** That number is the outer loop's limit, usually n.
2. **Write down the item count for rows 1, 2 and 3.** If it goes 1, 2, 3 the limit is i; if it goes 5, 4, 3 it is n - i + 1; if it goes 1, 3, 5 it is 2 * i - 1. If the left edge moves, count the spaces the same way.
3. **Look at one column.** If the same column shows the same value on every row, print j. If a whole row repeats one value, print i. If nothing repeats, find the formula in i and j, or a test that picks the edge.

The full-mark answer is the same shape every time: Scanner input for n, the nested loops, a `println()` after each row and a variable description table. Here is the pyramid, written that way.

***Pyramid.java**all four rules at once*

```
import java.util.Scanner;
class Pyramid {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter the number of rows: ");
        int n = sc.nextInt();
        for (int i = 1; i <= n; i++) {              // rows
            for (int s = 1; s <= n - i; s++)        // spaces
                System.out.print(" ");
            for (int j = 1; j <= 2 * i - 1; j++)    // stars
                System.out.print("*");
            System.out.println();                   // end of the row
        }
    }
}
```

Row i has n - i spaces and 2i - 1 stars. Check row 1 and row n by hand before writing anything else: 4 spaces and 1 star, then 0 spaces and 9 stars.

| Variable | Type | Purpose |
| --- | --- | --- |
| n | int | number of rows, read from the user |
| i | int | current row, 1 to n |
| s | int | counts the leading spaces in row i |
| j | int | counts the stars in row i |
| sc | Scanner | reads input from the keyboard |

***Sample run**Java 21*

```
Enter the number of rows: 5
    *
   ***
  *****
 *******
*********
```

Print a single space for each gap, not " ", or the slope doubles and the shape tilts.

Q2. How do you make a triangle grow or shrink?

## Triangle pattern ICSE: changing only the inner loop limit

A left-aligned triangle needs no spaces at all. Rows and characters stay fixed while the inner loop's limit decides the shape: `j <= i` grows, `j <= n - i + 1` shrinks.

| Pattern | Items in rows 1, 2, 3 | Inner limit | Printed |
| --- | --- | --- | --- |
| Star triangle | 1, 2, 3 | `j <= i` | `"* "` |
| Shrinking count | 5, 4, 3 | `j <= n - i + 1` | `j` |
| Row repeat | 1, 2, 3 | `j <= i` | `i` |

***RuleColumns.java**three triangles, three limits*

```
class RuleColumns {
    static void starTriangle(int n) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++)
                System.out.print("* ");
            System.out.println();
        }
    }
    static void shrinkingCount(int n) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n - i + 1; j++)
                System.out.print(j + " ");
            System.out.println();
        }
    }
    static void rowRepeat(int n) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++)
                System.out.print(i + " ");
            System.out.println();
        }
    }
    public static void main(String args[]) {
        starTriangle(5);
        System.out.println("--");
        shrinkingCount(5);
        System.out.println("--");
        rowRepeat(5);
    }
}
```

***Output**Java 21*

```
*
* *
* * *
* * * *
* * * * *
--
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
--
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
```

starTriangle and rowRepeat share the same loops and differ in one word: the star becomes i. That is the characters rule at work, and the reason to learn rules rather than shapes.

### The most common slips with these three

- **println inside the inner loop.** Every item lands on its own line and the triangle becomes a column.
- **n - i instead of n - i + 1.** The first row loses one item and the last row is empty. Test the limit with i = 1 and i = n.
- **Printing j where the row repeats.** If each row shows one value repeated, the value comes from the outer counter, i.

Q3. How do you push a pattern to the right?

## Star pattern program ICSE: right-aligned triangles, pyramids and the diamond

Add a spaces loop before the items. When row i has n - i spaces, row 1 starts furthest right and row n touches the margin, which turns a left triangle into a right-aligned one and, with 2i - 1 items, into the pyramid above.

***RuleSpaces.java**spaces first, then items*

```
class RuleSpaces {
    static void rightAligned(int n) {
        for (int i = 1; i <= n; i++) {
            for (int s = 1; s <= n - i; s++)
                System.out.print(" ");
            for (int j = 1; j <= i; j++)
                System.out.print("#");
            System.out.println();
        }
    }
    static void diamond(int n) {
        for (int i = 1; i <= n; i++) {              // top half, rows 1 to n
            for (int s = 1; s <= n - i; s++)
                System.out.print(" ");
            for (int j = 1; j <= 2 * i - 1; j++)
                System.out.print("*");
            System.out.println();
        }
        for (int i = n - 1; i >= 1; i--) {          // bottom half, rows n-1 down to 1
            for (int s = 1; s <= n - i; s++)
                System.out.print(" ");
            for (int j = 1; j <= 2 * i - 1; j++)
                System.out.print("*");
            System.out.println();
        }
    }
    public static void main(String args[]) {
        rightAligned(5);
        System.out.println("--");
        diamond(4);
    }
}
```

***Output**Java 21*

```
    #
   ##
  ###
 ####
#####
--
   *
  ***
 *****
*******
 *****
  ***
   *
```

The bottom half of the diamond is the same loop body as the top half, with the outer loop running backwards from n - 1. Starting it at n would print the widest row twice.

### How many spaces? A quick table for row i of n rows

| Shape | Spaces before row i | Items in row i | Item printed |
| --- | --- | --- | --- |
| Right-aligned triangle | `n - i` | `i` | `"#"` with no space after it |
| Pyramid (solid) | `n - i` | `2 * i - 1` | `"*"` with no space after it |
| Pyramid (spaced stars) | `n - i` | `i` | `"* "`, the trailing space does the widening |
| Inverted pyramid | `i - 1` | `2 * (n - i) + 1` | `"*"` |
| Diamond | pyramid of n rows, then inverted pyramid of n - 1 rows | as each half | `"*"` |

Spaces are where most pattern answers go wrong under exam pressure, so in the class every student draws the grid on squared paper first and writes the space count beside each row. The same habit of counting each pass is drilled on [loop programs in Java for ICSE Class 10](/icse-class-10-loop-programs-java).

Q4. How do number, letter and 0 1 patterns work?

## Number pattern Java Class 10: letters, 0 and 1, palindromes and hollow shapes

Once the rows, limits and spaces are right, the remaining work is the value printed at position (i, j). It can be a formula, a char made from a number, two loops that climb and then fall, or an if-else that picks the border.

| Pattern | What is printed at (i, j) | Why it works |
| --- | --- | --- |
| 0 1 triangle | `(i + j) % 2` | i + j changes parity at each step along a row and each step down a column |
| Letter triangle | `(char) ('A' + j - 1)` | 'A' is 65; adding j - 1 and casting back gives A, B, C |
| Palindrome pyramid | j from 1 up to i, then j from i - 1 down to 1 | Two inner loops: one climbs, one falls, so each row reads the same both ways |
| Hollow square | `"* "` when i or j is 1 or n, else two spaces | Only the border passes the test; the gap must be as wide as a star plus its space |
| Word triangle | `w.substring(0, i)` | Row i shows the first i letters, so one loop is enough |

***RuleChars.java**the value at row i, column j*

```
class RuleChars {
    static void binaryTriangle(int n) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++)
                System.out.print((i + j) % 2 + " ");
            System.out.println();
        }
    }
    static void letterTriangle(int n) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++)
                System.out.print((char) ('A' + j - 1) + " ");
            System.out.println();
        }
    }
    static void palinPyramid(int n) {
        for (int i = 1; i <= n; i++) {
            for (int s = 1; s <= n - i; s++)
                System.out.print(" ");
            for (int j = 1; j <= i; j++)        // climb: 1 to i
                System.out.print(j);
            for (int j = i - 1; j >= 1; j--)    // descend: i-1 to 1
                System.out.print(j);
            System.out.println();
        }
    }
    static void hollowSquare(int n) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (i == 1 || i == n || j == 1 || j == n)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }
    }
    static void wordTriangle(String w) {
        for (int i = 1; i <= w.length(); i++)
            System.out.println(w.substring(0, i));
    }
    public static void main(String args[]) {
        binaryTriangle(5);
        System.out.println("--");
        letterTriangle(5);
        System.out.println("--");
        palinPyramid(4);
        System.out.println("--");
        hollowSquare(5);
        System.out.println("--");
        wordTriangle("BLUEJ");
    }
}
```

***Output**Java 21*

```
0
1 0
0 1 0
1 0 1 0
0 1 0 1 0
--
A
A B
A B C
A B C D
A B C D E
--
   1
  121
 12321
1234321
--
* * * * *
*       *
*       *
*       *
* * * * *
--
B
BL
BLU
BLUE
BLUEJ
```

Without the cast, 'A' + j - 1 is an int and the letter triangle prints 65, 66, 67. The cast must wrap the whole sum, which is why it sits outside the brackets.

### Turn one pattern into another: practice changes

Each change below touches one rule only. Make it in BlueJ, predict the output first, then run it.

1. In `binaryTriangle`, print `(i + j + 1) % 2`. The triangle now starts with 1 instead of 0.
2. In `letterTriangle`, print `(char) ('A' + i - 1)`. Every row repeats one letter: A, B B, C C C.
3. In `palinPyramid`, remove the spaces loop. The rows become a left-aligned stack of palindromes.
4. In `hollowSquare`, add `|| i == j` to the test. A diagonal now crosses the square.
5. In `wordTriangle`, print `w.substring(w.length() - i)`. The word now builds from its last letter: J, EJ, UEJ.

Single letters printed with charAt instead of substring belong to the string family on [ICSE Class 10 string programs](/icse-class-10-string-programs), and tracing what a pattern prints without running it is practised on [ICSE Computer Applications output questions](/icse-class-10-java-output-questions).

Q5. Where do patterns appear in the ICSE paper?

## Pattern programs in the ICSE 2027 paper, and how they are marked

Patterns appear in two places: as a full Section B program, and very often as one part of a method overloading question, where one version of the method prints a pattern and the others do something else. They also turn up in Section A as short trace questions.

### Inside an overloading question

A recent pattern in board papers has been one method name with two or three parameter lists, one of which prints a number or symbol pattern. The pattern part is often the quickest marks in the question if the loop rules are second nature.

### As a menu choice

A switch menu may offer a pattern as option 1 and a series as option 2. The pattern code goes inside its case, followed by break, and the default case handles a wrong choice.

### As a trace in Section A

A short nested loop is shown and the student writes what it prints. The same rules work backwards: read the limits to find the item count per row.

### What earns the marks

Correct loops and limits, a println at the end of each row, sensible variable names, comments on what each loop does and the variable description table. A shape that is off by one row usually loses part of the logic marks.

### Check two rows by hand

Before moving on, trace row 1 and row n on the margin. Most wrong patterns are wrong at one end, and two quick traces catch both kinds of off-by-one.

### Keep it to for loops

A pattern can be printed with while loops, but for loops show the counter, the limit and the step on one line, which makes the logic easy for the examiner to follow.

Overloading answers with a pattern inside are worked on [user-defined methods and overloading for ICSE Class 10](/icse-class-10-user-defined-methods-overloading), and how often the pattern-in-overloading question came up in recent years is mapped on [ICSE Computer Applications previous year papers, solved](/icse-computer-applications-previous-year-papers-solved).

Q6. How are patterns taught in the live class?

## From squared paper to BlueJ: a pattern lesson in the mini batch

Students see a new shape, plan it with the three questions, write it by hand and only then type it. The plan is the skill; typing is the check.

1. #### A fresh shape on the shared screen

  At the Tuesday 5:30 PM IST class the teacher shows a pattern nobody has seen before, often a small variation of one on this page.
2. #### Rows, limits, spaces and value, written as a plan

  Each student writes the four answers in a box before any code: the outer limit, the inner limit in terms of i, the space count and the value printed.
3. #### Hand-written program, timed

  The program is written on paper against a clock, with a variable description table, as it would be in the paper.
4. #### Run in BlueJ, fixed in front of the group

  The best and the most instructive wrong answers are typed and run. A tilted pyramid or a missing row is traced back to the one limit that caused it.
5. #### Patterns inside full mock papers

  From December, patterns appear inside overloading and menu questions in complete two-hour mock papers, marked the way the board marks.

The other program families taught the same way are listed on [ICSE Class 10 Java programs for practice](/icse-class-10-java-programs-practice); the next two to learn after patterns are [series programs in Java](/icse-class-10-series-programs-java) and [menu driven programs with switch case](/icse-class-10-menu-driven-programs).

Batch or personalised: you choose

## Practise patterns in the mini batch, or one to one

Both formats use the four loop rules, the planning box and the BlueJ check. Families in India can choose the fixed evening mini batch or a private slot; ICSE students living abroad are taught one to one. Billing is monthly and there is no admission fee.

Option 1 · Fixed batch timings

### Mini batch, Tuesday 5:30 PM and Wednesday 8 PM

₹2,999

per month, two live classes a week

- Tuesday 5:30 PM and Wednesday 8:00 PM IST, live
- Up to six ICSE Class 10 students per batch
- A new pattern planned on paper most weeks
- Wrong shapes run and fixed while the group watches
- Patterns revisited inside overloading and menu questions

Book a free demo in this batch

Option 2 · Choose your own timing

### Personalised one to one

₹4,999

per month, one private class a week, at a time set with you

- A time chosen by the family, in India or abroad
- Extra time on whichever rule your child finds hard, often spaces
- Shapes chosen to match the school's own worksheets
- Harder patterns added once the basic triangles are secure
- Same teachers, same 2027 syllabus, same BlueJ checks

Ask for a personalised plan

A student who freezes at any pattern that is not in the textbook usually needs a few one to one sessions on the three questions, and then the shapes stop being a problem. A student who wants all of Section B practised week by week, with patterns as one family among several, fits the twice-weekly batch. Fees are shown in your own currency.

Studying outside India?

## Pattern program practice for ICSE students abroad

ICSE schools outside India set the same Computer Applications paper, so the same nested loop patterns turn up in their Section B. Overseas, the lessons run one to one at an early evening hour in the student's own time zone.

| Where you live | Time difference | Usual class window, local time | Format |
| --- | --- | --- | --- |
| India (IST) every Indian city | IST | Tue 5:30 PM, Wed 8:00 PM | Mini batch or 1-on-1 |
| United Arab Emirates Dubai, Sharjah | 1 h 30 min behind India | 3:00 PM to 9:00 PM | Personalised 1-on-1 |
| Indonesia and Thailand West Java, Bangkok area | 1 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1 |
| Singapore Singapore | 2 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1 |

The slot is fixed after the free demo and can move around school tests. Families overseas can read more on [ICSE Computer Applications classes in the Gulf and abroad](/icse-class-10-computer-applications-classes-gulf-and-abroad).

What families say

## Rated 4.9 across 547 Google reviews

Real reviews from real families. We neither write nor commission them.

★★★★★

"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."

Ria Mukherjee

Parent

★★★★★

"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."

Samriddha Mondal

Student

★★★★★

"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."

Vansh Agarwal

Student

★★★★★

"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."

Sonam Oswal

Parent of Dhairya

★★★★★

"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."

Sonu Goyal

Parent

★★★★★

"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."

Ritu Kedia

Parent

The rest of the Class 10 series

## More pages for Class 10 board students

Every page in the ICSE Class 10 Computer Applications series, grouped by what you need: classes, each chapter, Section B programs, question practice, notes and revision, and the exam itself.

### Classes, tuition and batches

- [The Tue and Wed ICSE Java batch](/icse-class-10-java-classes-online)
- [ICSE Java classes in the Gulf and abroad](/icse-class-10-computer-applications-classes-gulf-and-abroad)
- [ICSE BlueJ Java coaching](/icse-class-10-bluej-java-coaching)
- [ICSE computer crash course](/icse-computer-applications-crash-course)
- [ICSE computer tuition in Kolkata](/icse-computer-tuition-kolkata)
- [ICSE computer tuition in Bangalore](/icse-computer-tuition-bangalore)
- [ICSE computer tuition in Mumbai](/icse-computer-tuition-mumbai)
- [1-on-1 private Java tutor](/icse-computer-applications-private-tutor)
- [ICSE computer tuition in Lucknow](/icse-computer-tuition-lucknow)
- [ICSE computer tuition in Pune](/icse-computer-tuition-pune)
- [ICSE computer tuition near me](/icse-computer-tuition-near-me)
- [The mini batch, explained](/icse-computer-applications-small-batch-classes)

### Chapter by chapter

- [ICSE Computer Applications syllabus](/icse-class-10-computer-applications-syllabus-explained)
- [User-defined methods and overloading](/icse-class-10-user-defined-methods-overloading)
- [Constructors](/icse-class-10-constructors-questions)
- [Wrapper and library classes](/icse-class-10-wrapper-and-library-classes)
- [Class as the basis of all computation](/icse-class-10-class-as-basis-of-computation)
- [Encapsulation and access specifiers](/icse-class-10-encapsulation-access-specifiers)
- [Math library methods](/icse-class-10-math-library-methods)
- [Operators and expressions](/icse-class-10-operators-in-java)
- [Loops and loop conversion](/icse-class-10-loop-programs-java)
- [Data types, input and type casting](/icse-class-10-data-types-and-input-java)
- [Class 9 Java revision for Class 10](/icse-class-9-java-revision-for-class-10)

### Programs for Section B

- [ICSE Java programs practice](/icse-class-10-java-programs-practice)
- [String programs](/icse-class-10-string-programs)
- [Special number programs](/icse-special-number-programs-java)
- [Sorting and searching programs](/icse-class-10-sorting-and-searching-programs)
- [2D array programs](/icse-class-10-2d-array-programs)
- [Menu driven and switch case](/icse-class-10-menu-driven-programs)
- [Series programs](/icse-class-10-series-programs-java)
- [Slab and bill programs](/icse-class-10-slab-and-bill-programs)

### Questions and practice

- [ICSE CA important questions](/icse-class-10-computer-applications-important-questions)
- [Specimen paper and mock tests](/icse-class-10-computer-applications-specimen-paper-and-mock-tests)
- [Previous year papers, solved](/icse-computer-applications-previous-year-papers-solved)
- [Predict the output questions](/icse-class-10-java-output-questions)
- [Competency and case study questions](/icse-computer-applications-competency-questions)
- [MCQ for Question 1](/icse-computer-applications-mcq-questions)
- [Viva and oral questions](/icse-computer-applications-viva-questions)
- [Find the error questions](/icse-class-10-java-error-finding-questions)
- [Difference between questions](/icse-computer-difference-between-questions)

### Notes and revision

- [Chapter-wise notes](/icse-computer-applications-notes)
- [Textbook solutions guide](/icse-computer-applications-textbook-solutions-guide)
- [Worksheets with answers](/icse-computer-applications-worksheets)

### Exam, marks and internal assessment

- [ICSE board exam preparation](/icse-class-10-computer-applications-board-exam-preparation)
- [Exam date 2027 and paper pattern](/icse-class-10-computer-applications-exam-date-and-paper-pattern)
- [Project and internal assessment](/icse-class-10-computer-applications-project-and-internal-assessment)
- [How to score 100](/how-to-score-100-in-icse-computer-applications)
- [Paper analysis and answer key](/icse-computer-applications-paper-analysis)
- [Computer or Commercial Applications?](/icse-computer-applications-vs-commercial-applications)

**CBSE Class 10 AI (417):** [The Mon and Wed 9 PM AI batch](/cbse-class-10-ai-classes-online)  [CBSE AI 417 syllabus explained](/cbse-class-10-ai-syllabus-explained)  [CBSE AI important questions](/cbse-class-10-ai-important-questions)  [Sample paper and mock tests](/cbse-class-10-ai-sample-paper-and-mock-tests)

Questions about pattern programs

## What students ask about ICSE pattern programs

### How do I solve any pattern program in Java?

Answer three questions before coding. How many rows are there? That is the outer loop. How many items are in row i? That is the inner loop limit, written using i. What is printed at row i, column j? That is the print statement. If the shape is pushed to the right, add a spaces loop before the items. Then trace row 1 and the last row by hand.

### Are pattern programs important for ICSE Class 10?

Yes. They test nested loops, which are part of the 2027 Computer Applications syllabus, and they appear as Section B programs, as one part of method overloading questions and as Section A trace questions. A student who knows the loop rules can usually collect these marks quickly.

### What is the difference between print and println in pattern programs?

print leaves the cursor on the same line, so the items of one row sit side by side. println moves to a new line. In a pattern, print goes inside the inner loop and a single println goes after the inner loop, once per row. Putting println inside the inner loop prints every item on its own line.

### How do you print a star pyramid in Java?

Use an outer loop for i from 1 to n. Inside it, print n - i spaces, then 2 * i - 1 stars with no space between them, then call println. For n = 5 the first row has four spaces and one star, and the last row has nine stars and no spaces.

### How do you print a letter pattern such as A, AB, ABC in Java?

Print (char) ('A' + j - 1) inside the inner loop, where j runs from 1 to i. Adding a number to a char gives an int, so the cast is needed to turn the code back into a letter. Without it the program prints 65, 66 and 67.

### How do you print a 0 and 1 triangle pattern in Java?

Print (i + j) % 2 at row i, column j. The sum i + j changes between odd and even at every step, so the digits alternate along each row and each column. Use (i + j + 1) % 2 instead if the first row must start with 1.

### How do you print a hollow square or hollow triangle?

Loop over every position in the grid and use an if-else. Print the symbol when the position is on the border (first row, last row, first column or last column) and print blanks otherwise. The blank must be as wide as the symbol plus any space printed after it.

### Which loop is best for pattern programs?

The for loop, because the start, the limit and the step of each counter sit on one line, and a pattern is a fixed number of rows and items. While and do-while loops can print patterns too, but they make the limits harder to see and to mark.

### Is recursion used for patterns in ICSE 2027?

No. Recursion is not part of the ICSE Computer Applications syllabus for 2027. Every pattern the paper can ask is printed with nested for loops, sometimes inside a method that takes n, a character or a word as a parameter.

### Do you teach pattern programs in live classes?

Yes. In the ICSE mini batch a new pattern is planned on paper, written against the clock, then run and fixed in BlueJ on a shared screen. Students who need more time on nested loops can take personalised one to one classes at a time the family chooses.

Start

## Try a free live pattern programs class

In the free demo your child meets a pattern they have not seen before, plans it with the mentor using rows, limits, spaces and the printed value, writes the code and runs it in BlueJ. You then hear honestly whether nested loops are already secure, and whether the mini batch or one to one will help more.

Looking at the whole subject first? See [ICSE Computer Applications important questions](/icse-class-10-computer-applications-important-questions) or [the ICSE Class 10 Java classes](/icse-class-10-java-classes-online).

[WhatsApp us](https://wa.me/919123366161?text=Hello%20Modern%20Age%20Coders.%20I%20want%20help%20with%20ICSE%20Class%2010%20pattern%20programs%20in%20Java.) · [+91 91233 66161](tel:+919123366161) · [connect@modernagecoders.com](mailto:connect@modernagecoders.com)

Every class is live video. The form requests a callback and reserves nothing.

### Want it sooner? Book a priority demo

A full live class of about 45 to 60 minutes at a slot you pick, with a written skill report and learning roadmap on WhatsApp afterwards. The fee is adjusted against your first month if you enrol.

[Book a priority demo](/book-demo)

## Keep exploring Modern Age Coders

### By class and age

- [Difference Between Questions ICSE Computer Applications 2027](/icse-computer-difference-between-questions)
- [Java for ICSE & ISC Students](/java-programming-for-icse-students)
- [Best Book for Class 10 AI (417) in 2026-27, Compared](/best-book-for-cbse-class-10-ai)
- [Lambda Expressions and Streams API Practice](/resources/java/lambda-expressions-and-streams/practice)

### Learn more

- [Java Classes for Teens](/java-classes-for-teens)
- [Learn to Code Minecraft Mods in Java: A Guide for Teens](/learn-to-code-minecraft-mods)
- [Java Programming for Kids & Teens: Learn Java Online](/java-programming-for-kids-teens)
- [Online Java Classes](/online-java-classes)

### Free resources

- [Java Tutorial for Beginners to Advanced](/resources/java)
- [File Handling in Java](/resources/java/file-handling-in-java)
- [Introduction to Java](/resources/java/introduction-to-java)
- [Loops in Java (for, while, do-while)](/resources/java/loops-in-java)

### From the blog

- [Java Tutorials & Programs](/blog/topic/java)
- [Top 20 Java Programs for ICSE Class 10 (With Code)](/blog/top-20-java-programs-for-icse-class-10)
- [50 Important Java Programs for ICSE Class 10 Boards](/blog/50-java-programs-for-icse-class-10)
- [Java Constructors Explained: Types, Overloading, ICSE](/blog/java-constructors-explained)

### Start here

- [Real projects built by Modern Age Coders students](/student-labs)
- [Browse every live course at Modern Age Coders](/courses)

---

*Canonical: https://learn.modernagecoders.com/icse-class-10-pattern-programs-java*
