×

India Map Pattern in Java

India Map Pattern is the pattern we'll code now using Java, as demonstrated.

We will use a star in Java to print our India map.The specialty is that we will only utilize it for printing the India Map Pattern in loops.

Program for the India Map Pattern in Java

import java.io.*;
importjava.util.*;
public class IndiaMap
{
 public static void main(String[] args)
 {
for(int i=1; i<=2; i++)
  {
for(int j=1; j<=14; j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=4*i+2; j++)
    {
System.out.print("*");
    }
System.out.println();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<(12+i+i)+2; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=(2*8-i); j++)
    {
System.out.print("*");
    }
System.out.println ();
  } 
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=14+i; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=3*(4-i+2); j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=(12+i+i)+2; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=12; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=18; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=2*i+6; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=2*(9-i+1)-1; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=2*i+12; j++)
    {
System.out.print("*");
    }
System.out.println();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=2*(7-i+1); j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=3*i+13; j++)
    {
System.out.print("*");
    }
for(int j=1; j<=3*(11-i+1)+1; j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=5*i; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<2*(10-5*(i)+(i*2)-1)+i-1; j++)
    {
System.out.print (" ");
    }
for(int k=1; k<=7*i+16; k++)
    {
System.out.print("*");
    }
for(int j=1; j<=2*(8-i+1); j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=i; j++)
    {
System.out.print("*");
    }
for(int j=1; j<=4*(2-i+1)+1; j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=2*i+8; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }  
for(int i=1; i<=2; i++)
  {
for(int j=1; j<=i+4; j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=24*i+13; j++)
    {
System.out.print("*");
    }
for(int j=i; j<=1; j++)
    {
System.out.print("        **      ********");
    }
System.out.println();
  }
for(int i=1; i<=2; i++)
  {
for(int j=1; j<=i+6; j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=2*(22-i+2); j++)
    {
System.out.print("*");
    }
for(int j=1; j<=i; j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=12; j++)
    {
System.out.print("*");
    }
System.out.println();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=1-i+1; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=4+2*i; j++)
    {
System.out.print("*");
    }
for(int j=1; j<=1-i+1; j++)
    {
System.out.print(" ");
    }
    for (int j=1; j<=(40+i+i)+2; j++)
    {
System.out.print("*");
    }
    for (int j=1; j<=2*(4-i+1); j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=7-i; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=2*(2-i+1); j++)
    {
System.out.print (" ");
    }
    for (int j=1; j<=4*i+45; j++)
    {
System.out.print("*");
    }
    for (int j=1; j<=8; j++)
    {
System.out.print(" ");
    }
    for (int j=1; j<=2*(2-i+1)-1; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=3+i; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=7-i; j++)
    {
System.out.print("*");
    }
    for (int j=1; j<=1; j++)
    {
System.out.print (" ");
    }
    for (int j=1; j<=40-2*i+1; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=12-i+1; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=35; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=12; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=30; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=12; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=2*(14-i+1); j++)
    {
System.out.print("*");
    }
for(int j=i; j<=1; j++)
    {
System.out.print("  ");
    }
System.out.println ();
  } 
for(int i=1;i<=2;i++)
  {
for(int j=1;j<=i+11;j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=25-i+1; j++)
    {
System.out.print("*");
    }
for(int j=i; j<=1; j++)
    {
System.out.print("  ");
    }

System.out.println();
  }
for(int i=1;i<=2;i++)
  {
for(int j=1;j<=14;j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=20-i+1; j++)
    {
System.out.print("*");
    }
System.out.println();
  }
for(int i=1;i<=2;i++)
  {
for(int j=1;j<=i+14;j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=16; j++)
    {
System.out.print("*");
    }
System.out.println();
  }  
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=i+15; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=15-i+1; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 3; i++)
  {
    for (int j=1; j<=18; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=12; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=20; j++)
    {
System.out.print (" ");
    }
    for (int j=1; j<=10-2*i; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 1; i++)
  {
    for (int j=1; j<=21; j++)
    {
System.out.print (" ");
    }
    for (int j=1; j<=4; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
 }
}

The output of the above program

India Map Pattern in Java

Related Topics

Java Wrapper Class

Wrapper class in Java encapsulates a primitive type within an object. In other words, it is a unique mechanism of Java to convert primitive type in to object and object into primitive type....

3 minutes read.

Different Ways to Print Exception Message in Java

In this section, we will learn how to use various Java Throwable class methods to print exception messages. The Throwable class has the three methods listed below for printing the...

4 minutes read.

Java Throw and Throws Keyword

Exceptions in Java enable us to construct high-quality programs where faults are checked at compile time rather than run time and where we may define unique exceptions that make code...

6 minutes read.

Java Pass-by-Reference

In Java, passing parameters can be done using one of two fundamental methods. Pass-by-value is used for the first and pass-by-reference is used for the second. One thing to keep...

2 minutes read.

Java Naming Conventions

JAVA NAMING CONVENTIONS Java naming convention is a standard pattern for writing your identifier name such as class, interfaces, methods, constants, variable, etc. These patterns are not standard rules that you must...

2 minutes read.

Multiple Inheritance Programs in Java

A component of the object-oriented notion known as multiple inheritances allows a class to inherit properties from multiple parent classes. When methods that have the same signature are present in...

4 minutes read.

Java Enum

Enumerations are used in programming languages to represent collections of named constants. For instance, the four suits in a deck of playing cards might represent four iterators named Club, Diamond,...

3 minutes read.

Java Thread Priority in Multithreading

As we realise, java, being object-situated, works inside a multithreading climate in which the string scheduler relegates the processor to a string in light of the need for a string....

6 minutes read.

Packages in Java

Packages in Java can be defined as an assortment for grouping various classes and interfaces based on their performance. It is a catalog for holding various java files. They provide...

4 minutes read.

Java program to print matrix in Z form

In this article, you will be acknowledged about what is a matrix along with an example. Also, most importantly, you will learn how to print matrix in Z form. What is...

5 minutes read.

Kotlin Vs Java

Kotlin Vs Java There are many languages available for Android development. Java is the official language for android development but Kotlin is becoming popular nowadays. This article discusses both of these...

4 minutes read.

Java String copyValueOf() method

copyValueOf() method returns a String that holds the character sequence of the character array. Syntax: copyValueOf(char[] data) Parameters: data : the character array i.e. String Returns: It returns a String that contains the characters of the...

2 minutes read.

Replace character in string Java

Characters in Java In the package of Java language, there is a container class called Character. A single field of type char is contained in a Character object. For manipulating characters,...

4 minutes read.

Vector in Java

Java Vector Class The Vector class is a legacy class that implements a growable array of objects. The components that it contains can be accessed using an integer index. The size of...

26 minutes read.

Java Editors

A straightforward text editor may be used to create Java applications. However, a Java integrated programming environment (IDE) enables the software developer to create programs more quickly. An IDE offers...

4 minutes read.

Java Integer doubleValue() method

The doubleValue() method of Integer class returns a double value for this Integer after a widening primitive conversion. Syntax public double doubleValue() Parameters NA Specified by This method is specified by doubleValue in class Number Return Value This...

1 minute read.

Local Minima in Java

An Array Finding a local minimum in an array a[0. m-1] of different integers is the job. A[i] is considered a local minimum if it is smaller than two of its...

4 minutes read.

Java FileNotFoundException

FileNotFoundException is another exception class accessible in the java.io bundle. The exemption happens when we attempt to get to that document which isn't accessible in the framework. It is a checked...

5 minutes read.

Java Stringjoiner Class

StringJoiner is a class which is used to construct a sequence of characters which are separated by a delimiter. Optionally, it starts with a provided prefix and ended with the...

5 minutes read.

Java Project Ideas

When it comes to constructing projects, Java is regarded as one of the best languages and is also one of the most paid. Java excels in any application, whether it...

10 minutes read.