need help with outputting an array of objects to a text file. new to java so any help would be much appreciated

I assume you want to serialize your objects.

FileOutputStream fos = new FileOutputStream("objects.ext");
ObjectOutputStream oos = new ObjectOutputSream(fos);

You may have to implement Serializable if you want to write your own classes. If the classes of the java library doesnt implement Serializable just make a new class, extended of that class and implement it then without any other changes.
You just have to add

implement Serializable

after your

public class MyClass (extends .... whatever)

The Serializable interface doesnt have any methods you had to implement.

I want to know the logic for the output
0 1
0 1 2
0 1 2 3
0 1 2 3 4

import java.util.*;
class Logic
    Scanner in()
    {   return new Scanner(;  }

    void out(String n)
    {   System.out.print(n);    }

    public Logic()
        int n;
        out("Enter N: ");
        for(int i=0;i<=n;i++)
            for(int j=0;j<=i;j++)
                out(""+j+ " ");
    public static void main(String[] args)
    {   new Logic();    }


First post of each thread is a question and rest posts are conversation. If you have a problem regarding to programming then create a new thread.

Now, before you post any question please read the rules of this forum:
1. Homework Policy
2. How to post your question?

Use code tags. Wrap up source code with bb code tags.

For example,

[CODE=Java] ..... .... here is your program source code.