please answer this Java pattern
Attachments:
Answers
Answered by
0
Answer:
The Java Pattern class ( java.util.regex.Pattern ), is the main access point of the Java regular expression API. ... The Java Pattern class can be used in two ways. You can use the Pattern.matches() method to quickly check if a text (String) matches a given regular expression.
Explanation:
Answered by
1
Question:-
Write a program in Java to display the following pattern.
1
2 3
4 5 6
7 8 9 10
Program:-
import java.util.*;
class Pattern
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the number of rows: ");
int n=sc.nextInt();
int a=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
System.out.print(a++ + " ");
System.out.println();
}
}
}
Similar questions