0
How to print this pattern in java
$$ $ $ $ $ $$
3 Answers
+ 3
If you don't need user input, it's a fairly easy thing to do.
Printline 1 ($$)
Printline 2 ($ $)
Printline 3 ($ $)
Printline 4 ($$)
+ 1
import java.util.*;
// Compiler version JDK 11.0.2
class Dcoder
{
public static void main(String args[])
{
//System.out.println("Hello, Dcoder!");
int n = 4;
for(int i=1; i<=4; i++){
for(int j=1; j<=4; j++){
if((i==1&&(j>=1&&j<=n))||(i==n&&(j>=1&&j<=n))||j==1||j==n){
System.out.print("quot;);
}
else{
System.out.print(" ");
}
}
System.out.println();
}
}
}