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

I assume you want to serialize your objects.

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

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
0 1
0 1 2
0 1 2 3
0 1 2 3 4

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

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

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

soumitaabasu,

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?

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

For example,

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

[/code]

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.