473,795 Members | 2,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

returning values from Arraylist

17 New Member
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

Expand|Select|Wrap|Line Numbers
  1. class myClass{
  2.  
  3. public ArrayList<Rectangle> readFile()throws Exception {    
  4.          String n = null;
  5.         // List draw;
  6.     try{
  7.             BufferedReader fh = new BufferedReader(new FileReader("myInputFile.txt"));    
  8.             while(true){
  9.                n = fh.readLine();
  10.                if(n == null){
  11.                   break;
  12.                }else{
  13.                   String f[] = n.split("\t");
  14.  
  15.                         int iscntop = Integer.parseInt(f[3]);
  16.                         int iscnbot = Integer.parseInt(f[4]);
  17.                         int basestop = Integer.parseInt(f[5]);
  18.                         int basesbot = Integer.parseInt(f[6]);
  19.                         String stain = f[7];
  20.  
  21.                         List list = new ArrayList(Arrays.asList(f[3],f[4],f[5],f[6],f[7]));
  22.                         List draw = new ArrayList(Arrays.asList("g.drawRect("+f[3]+","+"60"+","+width+","+"27"+")"));
  23.                         List fill = new ArrayList(Arrays.asList("g.fillRect("+f[3]+","+"60"+","+width+","+"27"+")"));
  24.                         List color = new ArrayList(Arrays.asList("g.setColor"+"("+"Color."+f[7]+")"));
  25.  
  26.                       //  System.out.println(list);
  27.                         System.out.println(draw);
  28.                         System.out.println(color);
  29.                         System.out.println(fill);
  30.  
  31.                }
  32.  
  33.           }//end while
  34.           fh.close();
  35.  
  36.        } catch (FileNotFoundException e) {
  37.             e.printStackTrace();
  38.         }
  39.                                    return draw, fill, color // Howto return multiple arraylists. I want to use them in another class. 
  40.  
  41.    }//end of readFile
Thanks
May 11 '09 #1
1 3011
r035198x
13,262 MVP
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> .
May 11 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
7353
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...
2
4334
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!!
6
5512
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.
1
2579
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.
1
2068
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.
5
19600
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...
10
4741
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?
6
5809
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++)
2
2636
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...
0
9673
marktang
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...
0
9522
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,...
0
10448
Oralloy
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...
0
10217
jinu1996
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...
0
10003
tracyyun
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...
0
9046
agi2029
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...
0
5440
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...
0
5566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.