Hi. I want to return values from multiple Arraylist. How can I do that ? later I want to use these values in another class. Can somebody help - class myClass{
-
-
public ArrayList<Rectangle> readFile()throws Exception {
-
String n = null;
-
// List draw;
-
try{
-
BufferedReader fh = new BufferedReader(new FileReader("myInputFile.txt"));
-
while(true){
-
n = fh.readLine();
-
if(n == null){
-
break;
-
}else{
-
String f[] = n.split("\t");
-
-
int iscntop = Integer.parseInt(f[3]);
-
int iscnbot = Integer.parseInt(f[4]);
-
int basestop = Integer.parseInt(f[5]);
-
int basesbot = Integer.parseInt(f[6]);
-
String stain = f[7];
-
-
List list = new ArrayList(Arrays.asList(f[3],f[4],f[5],f[6],f[7]));
-
List draw = new ArrayList(Arrays.asList("g.drawRect("+f[3]+","+"60"+","+width+","+"27"+")"));
-
List fill = new ArrayList(Arrays.asList("g.fillRect("+f[3]+","+"60"+","+width+","+"27"+")"));
-
List color = new ArrayList(Arrays.asList("g.setColor"+"("+"Color."+f[7]+")"));
-
-
// System.out.println(list);
-
System.out.println(draw);
-
System.out.println(color);
-
System.out.println(fill);
-
-
}
-
-
}//end while
-
fh.close();
-
-
} catch (FileNotFoundException e) {
-
e.printStackTrace();
-
}
-
return draw, fill, color // Howto return multiple arraylists. I want to use them in another class.
-
-
}//end of readFile
Thanks
1 3011
Why not create a class that holds draw, fill, color e.t.c as members. You then just create and return one ArrayList instead of returning a List<ArrayList> .
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dan |
last post by:
Hello,
I'm getting started on my first java project. I'm likely going to use
jsp/servlets connected to javabeans. The beans will connect to my
backend and get/set information for me. When returning database
records from the bean, what common methods to people use? I've seen
records returned as arraylists, but I'm not sure I like this method
too well. To get the information in the next column, I can use
nextElement(), but then I'm...
|
by: Z D |
last post by:
Hello,
I'm currently using Remoting (HTTP/Binary) to remote a simple object.
Everything is working fine except for one function that returns an arraylist
of datatables.
When I call this function, nothing is returned (ie length of array =0).
However, if I comment out my config file so that the DLL is run locally
instead of remoting it, everything works fine!!
|
by: Ieuan |
last post by:
Hello all and Happy New Year,
I've been having this problem for some time and thought I'd try to see
if anyone else out there has had the same problem or can give a little
help.
I'm using a website written in C# to call a .dll which in turn returns
a load of information. Most of this information is readable. However,
some of the information returned is of type VBA.CollectionClass.
|
by: Ed. |
last post by:
I have an ArrayList of objects of class C. I need to return the list via a
web method. What's the best approach? If I convert the list into a DataSet
I could return the DataSet, but how would I do that? Do I need to create a
strongly typed DataSet from my class C?
Thanks.
|
by: Matthias De Ridder |
last post by:
Hello,
I really hope that someone will be able to help me, because I'm desperate now!
I'm a student, graduating this year, and I'm working on a thesis where C#
Web Services are involved. I only have three weeks to finish it all!
My GUI and Web services were finished, but I hadn't tested them. So I linked
the GUI to the Web service and started testing them.
| |
by: Stacey Levine |
last post by:
I have a webservice that I wanted to return an ArrayList..Well the service
compiles and runs when I have the output defined as ArrayList, but the WSDL
defines the output as an Object so I was having a problem in the calling
program. I searched online and found suggestions that I return an Array
instead so I modified my code (below) to return an Array instead of an
ArrayList. Now I get the message when I try to run just my webservice...
|
by: Sek |
last post by:
I have a property that returns a ArrayList object.
On failure condition, is it right to return null or return an ArrayList
object with zero elements?
|
by: Pavel Maly |
last post by:
Hi,
how do I access values in an ArrayList which is a part of another ArrayList? I know I can define
a class and then it is quite simple, but this is just an auxiliary application to compute some
values used later in the program. There must be a simpler way to achieve this without defining
any (even temporary) class.
Simple example:
ArrayList OuterAL = new ArrayList();
for (int i = 0; i < OuterBound; i++)
|
by: =?Utf-8?B?RHJldw==?= |
last post by:
I have a current requirement to all a subsidiary to use a current legacy
application and interface with my new system to inject data when appropriate.
I wanted to create a web service since we are both .Net shops and this would
seem to be the easiest method. But I ran into one snafu. I wanted to return
to the subsidiary an ArrayList of my Organization objects which contain the
orgs id, name etc. so they can use that information in the data...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |