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

Java Nested

Uploaded by

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

Java Nested

Uploaded by

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

// writing code for a patterin the java

import [Link];
public class main{
public static void main(String[]args){
Scanner sc = new Scanner([Link]);
int n = [Link]();
for(int i = 1; i<=n; i++){
for(int j = 1; j<=n; j++){
if(i==1 || j==1 || j==n || i==n|| i==j || j==n-i+1)
{
[Link]("*");
}
else
{
[Link](" ");
}
}
[Link]("");
}
}
}
// 8
// ********
// ** **
// * * * *
// * ** *
// * ** *
// * * * *
// ** **
// ********

// printign right angle triangle with the help of the nested loop
public class main{
public static void main(String[]args){
for(int i = 1 ; i<=5; i++){
for(int j = 1; j<=i; j++){
[Link]("*");
}
[Link]();
}
}
}
// *
// **
// ***
// ****
// *****

// printign right angle triangle with the help of the nested loop
public class main{
public static void main(String[]args){
for(int i = 1 ; i<=5; i++){
for(int j = 1; j<=5; j++){
[Link]("*");
}
[Link]();
}
}
}
/* *****
*****
*****
*****
***** */

You might also like