Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6699871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:44:51+00:00 2026-05-26T06:44:51+00:00

I had a question regarding this program I was trying to write. fin =

  • 0

I had a question regarding this program I was trying to write.

fin = new FileInputStream (args[0]);
            BufferedReader d = new BufferedReader(new InputStreamReader(fin));
            String str;

            while ((str = d.readLine()) != null) {
                String [] string = str.split(" ");
                System.out.println(string[0]);
                int i=0;
                if(!(string[0].compareTo("INPUT")==0) ||  (string[0].compareTo("OUTPUT")==0))
                {
                    // solution goes here

                }
            }

            fin.close();        

So the question i have is that i am trying to create objects a1, a2, a3 etc of a class (say A) and then add them as a vertex to a graph. Is there a way to define them dynamically? Would this work?

A [] a;
while(condition is true)
{
 a[i].setParameters() // dont worry about this
 graph.addVertex(a[i])
 i++;
}

If not, can you tell me a better way of doing this? When i try this i get local variable not initialized error. I might be missing something trivial

Note:
The project is to design a logic circuit simulator and I am trying to implement a graph styled data structure where nodes depict gates and the interconnects will be edges (I have two classes called gates and interconnects)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:44:51+00:00Added an answer on May 26, 2026 at 6:44 am

    It is hard to tell if this fixes all of your problems, since you didn’t provide a precise error message. At least it resolves a problem. You never created objects in your array.
    You’d have to know the since upfornt to do so, or you can achieve the desired behavior just like this:

    while(condition is true)
    {
     A a = new A();
     a.setParameters(); // dont worry about this
     graph.addVertex(a);
     // If you also need it in some kind of array, add it to the array, too.
     // Might be nice to use Vector<A> or List<A> aList = new ArrayList<A>() 
     // since those two can outmaticcaly grow while inserting at the back.
     // Create those outside of the loop if you need them at all.
     i++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a quick question regarding RegEx... I have a string that looks something
I had this question earlier and it was concluded it was a bug in
i had a question in my program. When I pass the 3D int array
We've had this question already, but I want to narrow it down to already
I always had this question: When i dont mind the exact floating number Which
I've just had a nagging question for a while regarding iPhone app user interfaces.
I had a quick question regarding the datacontractserializer. Maybe it's more of a stream
I have a question this time around regarding the Android custom camera, NOT the
I had a question regarding the split function used in Visual Basic. As of
I am working with a PHP loop, and I had one question regarding how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.