Ok, I am totally confused - probably because I've been staring at my computer for hours, but I need some guidance (not for homework, just my own personal knowlegde)...

Here's the output I'm trying to achieve:

012343210
001234321
000123432
000012343
000001234

...And I know I need to use a for loop. I would know how to get it to count up to 4, but to then count down from 4, I get confused there (also adding the 0's for each new line, etc.). Anyone have any ideas? It's probably an easy setup, just one detail that's not clicking in my head, but it's just wracking my brain, so I figured someone could rather "tutor" me on this quick. Thanks! :)

Create a single array of characters to print that can print the entire sequence, then create a loop where the loop index is used to determine where in the array to start.

Agree

having same problem but slightly differnt.ineed my software to preoduce number inequence like
00000001
00000002
00000003
...
..
00000100
and assign it to a user everytime it registers a new user

Agree with previous post.
Basically:
-Create an int array lengthed 5 that has the values from 0 to 4
-use for loop:

for(int a=0; 0<arrayName.length(); a++)
{
   if(count==9)
    {
       count=0;
       System.out.println("");
     }
   count++;
   System.out.print(arrayName[a]);
}

if(count==9)
{
   count=0;
   System.out.println("");
}
count++;
System.out.print("0");

for(int a=4; 0=<a; a--)
{
   if(count==9)
   {  count=0;
       System.out.println("");
   }
   count++;
   System.out.print(arrayName[a]);
}

Havn't complied this, so double check. But I'm sure it'll work =)!
Goodluck =)
please mark as solved if this its what you were looking for.

having same problem but slightly differnt.ineed my software to preoduce number inequence like
00000001
00000002
00000003
...
..
00000100
and assign it to a user everytime it registers a new user

mmm create a new thread so you can get exclusive help as its not the same thing.

import java.io.Serializable;

public class MyObjectToSerialize implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private int autogeneratedNumber;

	public MyObjectToSerialize(int autogeneratedNumber) {
		this.autogeneratedNumber = autogeneratedNumber;
	}

	public String toString() {
		return autogeneratedNumber + "";
	}

	public int getAutogeneratedNumber() {
		return autogeneratedNumber;
	}

	public void setAutogeneratedNumber(int autogeneratedNumber) {
		this.autogeneratedNumber = autogeneratedNumber;
	}

}


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.text.DecimalFormat;
import java.text.NumberFormat;

public class ObjectSerialization {

	private static void saveObject(Serializable object, String filename)
			throws IOException {
		ObjectOutputStream objstream = new ObjectOutputStream(
				new FileOutputStream(filename));
		objstream.writeObject(object);
		objstream.close();
	}

	private static Object loadObject(String filename)
			throws ClassNotFoundException, IOException {
		ObjectInputStream objstream = new ObjectInputStream(
				new FileInputStream(filename));
		Object object = objstream.readObject();
		objstream.close();
		return object;
	}

	public static void main(String[] args) {
		// MyObjectToSerialize original = new MyObjectToSerialize(0);
		try {
			// saveObject(original, "C:/serializable.ser");
			MyObjectToSerialize loaded = (MyObjectToSerialize) loadObject("C:/serializable.ser");
			loaded.setAutogeneratedNumber(loaded.getAutogeneratedNumber() + 1);
			saveObject(loaded, "C:/serializable.ser");
			System.out.println(String.format("%08d", loaded.getAutogeneratedNumber()));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

SNIP

ok. I have solved your "0" problem

class newbie
{
  public static void main(String args[])
 {
 int i,j;
 for(i=0;i<6;i++)
 {
  for(j=0;j<i;j++)
  {
  System.out.print(0);
  }
System.out.println();
  }
 }
}

Now let me see how much u have tried before i give u the solution

@akulkarni

I think instead of using for loops you can use String.format function as below:

System.out.println(String.format("%08d", number));

SNIP

ya i did think of using string ; with for i found it tough.i thought i could get with it with for loops but i failed.

int z=0;       
   for(int x=1; x<=5; x++){
       for(int y=1; y<=x; y++){
           System.out.print("0");
       }
       for(int a=1; a<=4; a++){
           if(a==4){
                   for(int y=a; y>=z; y--){
                       System.out.print(y);
                   }
                   z++;
           }else{
               System.out.print(a);
           }
       }
       System.out.println();
   }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.