[Resolved] Need help with JAVA code

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

zk0

Established Member
Impact
3
Need help with JAVA code

Hey! It's me again :)

I want to create the following pattern:
Code:
* * * * * * * * 
 * * * * * * * * 
* * * * * * * * 
 * * * * * * * * 
* * * * * * * * 
 * * * * * * * * 
* * * * * * * * 
 * * * * * * * *

Using only this line of code:
Code:
System.out.print(" ");
System.out.print("* ");
System.out.println();

So I need some loop codes to make this work. This is the code I got now:
Code:
public class stars {

	public static void main(String[] args)
	{
	        for (int i = 0; i < 4; ++i)
	        {
	        	System.out.print("* ");
	        	System.out.println();
	        
	        for (int k = 0; k < 1; ++k)
		        {
		        	System.out.print(" ");
		        	System.out.print("* ");
		        	System.out.println();
		        }
	        }
}
}

That code makes it look like this:
Code:
* 
 * 
* 
 * 
* 
 * 
* 
 *

What do I miss?
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Answered on webmasters-meet.com .

Nick
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back