comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * PRINTING DIAMOND SHAPE WITH LOOPS! - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/56cb33b6025f97a2 * Access to Wireless LAN ... - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4b6710a272f95e58 * Custom scrollbar thumb - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f7449e31ee33ed94 * PCMCIA and COMM API - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d08b61cd45fd7071 * web.xml - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/963f10a9a312d80 * RMI, JINI or RMI/IIOP - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1653768295c592a8 * accessing RecordStore - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a7023a70dfe7518b * render jsp to send in javamail - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c7a6deefb3778793 * odds and evens numbers - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/251f34d2dc2107b6 * Help with BigInteger addition - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e0475369c4bb5de * Applets, Security and JVM Support - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b7da802142fe04f7 * Using GridBagLayout with JFrame - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6dab24e12aab0546 * ArrayList problem - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4063b7309bedf3aa ========================================================================== TOPIC: PRINTING DIAMOND SHAPE WITH LOOPS! http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/56cb33b6025f97a2 ========================================================================== == 1 of 3 == Date: Wed, Aug 25 2004 2:00 am From: Paul Lutus <[EMAIL PROTECTED]> Jay Dean wrote: > I need simple nested loops (either for, or while) code for a method to > print a diamond shaped stars for n stars, where n is odd. > Example. n=9 would produce > > * > *** > ***** > ******* > ********* > ******* > ***** > **** > * > I have STRUGGLED with this for over three days in a row and my head > aches! Well, since you aren't really interested in learning this: void drawDiamond(int n) { int q = n/2; for(int a = -q;a <= q;a++) { int b = (a < 0)?-a:a; int c = q-b; for(int d = 0;d <= q+c;d++) { System.out.print((d < b)?" ":"*"); } System.out.println(); } } n = 9: * *** ***** ******* ********* ******* ***** *** * We would gladly teach you how to fish, but you clearly want to be handed the fish. So be it. -- Paul Lutus http://www.arachnoid.com == 2 of 3 == Date: Wed, Aug 25 2004 2:12 am From: "Chris Uppal" <[EMAIL PROTECTED]> Jay Dean wrote: > However, it is very *ridiculous* for a lot of helpers to *assume* > that most questions are HOMEWORKS. I would say that it's very sensible assumption. Not only is it the assumption I made myself, but I would question the sense/experience of anyone who /didn't/ make it. > You certainly don't know me, and > can't tell me for sure that I am in school. Exactly, that's why we have to assume what's most probable given incomplete information. There have been before, and there will be again, cases where people post requests for help with trivially simple exercises who are not looking for help with schoolwork, but such cases are in the small minority. BTW, please don't take offence at the phrase "trivially simple" -- it /is/ trivial for any working (or otherwise experienced) programmer, but everyone has to start somewhere. > Even if it were a homework, > and you "help" a student it is the student who is "hurting" > him/herself. If you can help somebody, help him/her. You have nothing > to lose by doing that. You may find this hard to believe, but /ALL/ of the responses you got were genuine attempts to help you. It may not have been the help you /thought/ you needed, but they were all offering constructive advice in their own ways. BTW, now that you've been given a complete solution (which I haven't bothered to read) I advise you to see if you've learned anything from it. I suggest you close down your newsreader (so you are not tempted to "cheat") and then see if you can solve the problem on your own. You will almost certainly find it easier to start with couple of simpler problems, first to print a simple triangle: * ** *** **** and then to print a backwards triangle: * ** *** **** -- chris == 3 of 3 == Date: Wed, Aug 25 2004 5:43 am From: John <[EMAIL PROTECTED]> Paul Lutus wrote: > Jay Dean wrote: > > >>I need simple nested loops (either for, or while) code for a method to >>print a diamond shaped stars for n stars, where n is odd. >> Example. n=9 would produce >> >> * >> *** >> ***** >> ******* >> ********* >> ******* >> ***** >> **** >> * >> I have STRUGGLED with this for over three days in a row and my head >>aches! > > > Well, since you aren't really interested in learning this: > > void drawDiamond(int n) > { > int q = n/2; > for(int a = -q;a <= q;a++) { > int b = (a < 0)?-a:a; > int c = q-b; > for(int d = 0;d <= q+c;d++) { > System.out.print((d < b)?" ":"*"); > } > System.out.println(); > } > } > > n = 9: > > * > *** > ***** > ******* > ********* > ******* > ***** > *** > * > > We would gladly teach you how to fish, but you clearly want to be handed the > fish. So be it. > Nice solution. The OP might be able to explain its workings to the lecturer though. Here's a more confusing version. I just wish I could justify some bitwise operations here. static void drawDiamond(int n) { for(int i = -n/2;i <= n/2; i++) { for(int j=0;j <= n-1-((i < 0)?-i:i);j++) { System.out.print((j < ((i < 0)?-i:i))?" ":"*"); } System.out.println(); } } ========================================================================== TOPIC: Access to Wireless LAN ... http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4b6710a272f95e58 ========================================================================== == 1 of 3 == Date: Wed, Aug 25 2004 2:02 am From: "Marco Cavaliere" <[EMAIL PROTECTED]> Hi everybody, I'm new to java programming, so be patient! :-) I'm start to programming java one mounth ago, and I'm try to programming a smart-client for WLAN access, basically I need to change the ESSID for my Wireless lan CARD, and of course, I need also to retrive the list of all ESSID that the card detect, is it possible do it with java? In linux I plan to use the commands: iwlist and iwconfig ... but in windows I've no idea! Any suggest? -- Posted via Mailgate.ORG Server - http://www.Mailgate.ORG == 2 of 3 == Date: Wed, Aug 25 2004 2:04 am From: Paul Lutus <[EMAIL PROTECTED]> Marco Cavaliere wrote: > Hi everybody, I'm new to java programming, so be patient! :-) > > I'm start to programming java one mounth ago, and I'm try to programming > a smart-client for WLAN access, basically I need to change the ESSID > for my Wireless lan CARD, and of course, I need also to retrive the list > of all ESSID that the card detect, is it possible do it with java? No. > > In linux I plan to use the commands: iwlist and iwconfig ... but in > windows I've no idea! You cannot do this without calling native methods. This is not a Java issue. -- Paul Lutus http://www.arachnoid.com == 3 of 3 == Date: Wed, Aug 25 2004 2:43 am From: "Marco Cavaliere" <[EMAIL PROTECTED]> "Paul Lutus" <[EMAIL PROTECTED]> wrote in message > > I'm start to programming java one mounth ago, and I'm try to programming > > a smart-client for WLAN access, basically I need to change the ESSID > > for my Wireless lan CARD, and of course, I need also to retrive the list > > of all ESSID that the card detect, is it possible do it with java? > No. > You cannot do this without calling native methods. This is not a Java issue. Bad to hear this! So the only way to make it is to use external commands? that are able to set up the network proprieties. If I've understood well! -- Posted via Mailgate.ORG Server - http://www.Mailgate.ORG ========================================================================== TOPIC: Custom scrollbar thumb http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f7449e31ee33ed94 ========================================================================== == 1 of 2 == Date: Wed, Aug 25 2004 2:04 am From: Paul Lutus <[EMAIL PROTECTED]> Ste M wrote: > Hi all, > i'm writing an application using UIManager and metal theme. > I'd like to use a bitmap to have a custom scrollbar thumb, but how can i > do it ? Java programming? When you have some code, post it. -- Paul Lutus http://www.arachnoid.com == 2 of 2 == Date: Wed, Aug 25 2004 2:14 am From: "Chris Uppal" <[EMAIL PROTECTED]> Paul Lutus wrote: > > i'm writing an application using UIManager and metal theme. > > I'd like to use a bitmap to have a custom scrollbar thumb, but how can i > > do it ? > > Java programming? > > When you have some code, post it. ?! This has to be in the running for some kind of "Most Useless Response of the Week" award. -- chris ========================================================================== TOPIC: PCMCIA and COMM API http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d08b61cd45fd7071 ========================================================================== == 1 of 1 == Date: Wed, Aug 25 2004 2:57 am From: JScoobyCed <[EMAIL PROTECTED]> Christian Marko wrote: > Hi! > > Does anyone have experiences with the COMM API and the usage of the > PCMCIA port? With the COMM API the PCMCIA ports should also be found, > or not? > > I have a PCMCIA port on my notebook, but this port won't be found, by > the appropriate class of the COMM API. As i read in other posts, the > port should be found. Can anyone help me? > > Regards > Chris I would hardly believe the PCMCIA port could be found by the COMM API: "The Java Communications API contains support for RS232 serial ports and IEEE 1284 parallel ports" (http://java.sun.com/products/javacomm/index.jsp) -- JScoobyCed What about a JScooby snack Shaggy ? ... Shaggy ?! ========================================================================== TOPIC: web.xml http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/963f10a9a312d80 ========================================================================== == 1 of 3 == Date: Wed, Aug 25 2004 2:59 am From: "vivienne wykes" <[EMAIL PROTECTED]> Hi All, I have a working shopping cart using jsp/java beans. I am confused as to what the purspose of the web.xml file does in the great scheme of things. Could anyone give me a short simple explanation of its purpose or point to where I might find a simple explantion on the web. I am familliar with Java and OO concepts. regards Viv == 2 of 3 == Date: Wed, Aug 25 2004 4:25 am From: Sudsy <[EMAIL PROTECTED]> vivienne wykes wrote: > Hi All, > > I have a working shopping cart using jsp/java beans. I am confused as to > what the purspose of the web.xml file does in the great scheme of things. <snip> The DTD itself contains documentation. You can find it here: <http://java.sun.com/j2ee/dtds/web-app_2_2.dtd> To wit: > The web-app element is the root of the deployment descriptor for > a web application == 3 of 3 == Date: Wed, Aug 25 2004 6:17 am From: "William Brogden" <[EMAIL PROTECTED]> On Wed, 25 Aug 2004 09:59:27 GMT, vivienne wykes <[EMAIL PROTECTED]> wrote: > Hi All, > > I have a working shopping cart using jsp/java beans. I am confused as to > what the purspose of the web.xml file does in the great scheme of things. > > Could anyone give me a short simple explanation of its purpose or point > to > where I might find a simple explantion on the web. I am familliar with > Java > and OO concepts. > > regards > > Viv web.xml is the deployment descriptor for web applications download the servlet specification from: http://java.sun.com/products/servlet/reference/api/index.html for a highly detailed explanation of the configuration options -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ ========================================================================== TOPIC: RMI, JINI or RMI/IIOP http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1653768295c592a8 ========================================================================== == 1 of 2 == Date: Wed, Aug 25 2004 3:00 am From: [EMAIL PROTECTED] (Buu Nguyen) Hi everyone, Our company is gonna develop a distributed Java project with thin Swing UI. We are considering the technology to use. In the course of performance, which technology, in the 3 RMI, JINI and RMI/IIOP, is better? It's best if someone can tell which is the commonly used technology in our case? Thanks and regards! == 2 of 2 == Date: Wed, Aug 25 2004 4:28 am From: Sudsy <[EMAIL PROTECTED]> Buu Nguyen wrote: > Hi everyone, > > Our company is gonna develop a distributed Java project with thin > Swing UI. We are considering the technology to use. In the course of > performance, which technology, in the 3 RMI, JINI and RMI/IIOP, is > better? It's best if someone can tell which is the commonly used > technology in our case? If you'll ever need to communicate with legacy applications then you'll probably want to go for IIOP. It lets you speak CORBA. RMI is fairly straight-forward but limits you to Java (in most cases). Don't know nuthin about JINI, sorry... ========================================================================== TOPIC: accessing RecordStore http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a7023a70dfe7518b ========================================================================== == 1 of 1 == Date: Wed, Aug 25 2004 3:14 am From: JScoobyCed <[EMAIL PROTECTED]> Marcin wrote: > Hi, > > I have a Nokia 6100 phone and I'm develoiping application that stores > data via RecordStore class. The problem is I would like to have those > data on my PC (i.e. via infrared link). > > Ideas: > 1) Use infrared API - probably not possible :( Why not. Using an IR to Serial application on your PC, and the JCA (Java Comm API) you can exchange data between your phone and a computer. > 2) not to use RecordStore but other class (if exists) that allows me > to create file (in Gallery folder maybe?). The I could access the file > from Nokia PC Suite. No. You are restricted to access data created by the JVM. You can't access directly to the File System of your phone. > 3) Access file there RecordStore records are stored (RMS.rms?) - but > how? I am not sure about that. I would go for a IR 2 Serial emulation on your PC, and communicate with the IR RFCOMM serial connection (provided it is working on the 6100). Another way would be to have a (web-)server on the PC and connect it through a (Http)Connection. -- JScoobyCed What about a JScooby snack Shaggy ? ... Shaggy ?! ========================================================================== TOPIC: render jsp to send in javamail http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c7a6deefb3778793 ========================================================================== == 1 of 1 == Date: Wed, Aug 25 2004 3:29 am From: F <[EMAIL PROTECTED]> Mark <[EMAIL PROTECTED]> wrote: > Hi all, > > Just wondering if anyone knew of a way to render the output of a jsp > page without printing it to the browser and then send that html as a > message through javamail... i.e. An invoice part of a web app that > allows you to either see your invoice through the browser or have it > sent to you via email. The invoice is presented to the browser as a > jsp page. I would like to send that same jsp page, after it has been > rendered, via email. I am trying to accomplish this in a Struts > application, so I would probably have an ActionServlet try and > accomplish this and then forward the user to a confirmation page. > Can't you just call your JSP from anywhere in your application and fetch the result using java.net.URL? Isn't that easier? You can just call a servlet or JSP which first calls the JSP to fetch the HTML, mail it and then redirect to that JSP. F ========================================================================== TOPIC: odds and evens numbers http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/251f34d2dc2107b6 ========================================================================== == 1 of 1 == Date: Wed, Aug 25 2004 3:48 am From: Joona I Palaste <[EMAIL PROTECTED]> Liz <[EMAIL PROTECTED]> scribbled the following: > "Paul Lutus" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Liz wrote: >> > Hay, forget double, how about String?? "42" is an integer. >> > Do we need "isEven(String a); >> >> That would be presumptuous, since a string is not a number at all. > It is a place to put the integer, just like double is a place to put the > integer. > ncest pas? By that logic, we would need Math.isEven() and Math.isOdd() methods for every class that contains an int or double field. -- /-- Joona Palaste ([EMAIL PROTECTED]) ------------- Finland --------\ \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/ "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners." - Ernst Jan Plugge ========================================================================== TOPIC: Help with BigInteger addition http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e0475369c4bb5de ========================================================================== == 1 of 3 == Date: Wed, Aug 25 2004 4:37 am From: Bert Sierra <[EMAIL PROTECTED]> OK -- Most of the Java API makes sense to me, but there are aspects of the java.math.BigInteger package that have me stumped. Any help would be appreciated. In one piece of code, I was trying to add two BigIntegers, as follows: BigInteger a = ...something... BigInteger b = ...something... BigInteger c = a.add(b); What I quickly discovered was that in some cases the result was returned by destroying the value in a, and in other cases by destroying the value in b. I couldn't see a pattern that would explain this behaviour, and unfortunately in the code I was working with I needed consistent behaviour. The Sun API doc was fairly vague, claiming only that add(val) would return a BigInteger whose value is (this + val) [see <http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html#add(ja va.math.BigInteger)>]. It wouldn't explain any side effects of the addition on the original arguments -- whether the addition would recycle the objects used, or would result in a new BigInteger being created. In the end, I had to augment my code to make copies of the original BigIntegers prior to the addition, as shown below. I don't like the fact that I'm creating additional objects, but it's necessary because I can't figure out how add() [and subtract() and multiply()] operates: BigInteger a = ...something... BigInteger b = ...something... BigInteger acopy = new BigInteger( a.toByteArray() ); BigInteger bcopy = new BigInteger( b.toByteArray() ); BigInteger c = acopy.add(bcopy); Seems like an awful lot of work to safely add two integers!! TIA for any advice.... == 2 of 3 == Date: Wed, Aug 25 2004 4:52 am From: Michael Borgwardt <[EMAIL PROTECTED]> Bert Sierra wrote: > In one piece of code, I was trying to add two BigIntegers, as follows: > BigInteger a = ...something... > BigInteger b = ...something... > BigInteger c = a.add(b); > > What I quickly discovered was that in some cases the result was returned > by destroying the value in a, and in other cases by destroying the value > in b. That's impossible unless your Java implementation is very broken. More likely, your code is broken. > The Sun API doc was fairly vague, claiming only that add(val) would > return a BigInteger whose value is (this + val) [see > <http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html#add(ja > va.math.BigInteger)>]. It wouldn't explain any side effects of the > addition on the original arguments -- whether the addition would recycle > the objects used, or would result in a new BigInteger being created. There is no vagueness. The very first word of the API doc for BigInteger is "Immutable". A BigInteger, once created, will not change, ever. So there *are no* side effects. There are, however, cases where the object returned will be one of the two objects that were added (if the other one is 0). Try to write a program as simple as possible that demonstrates this "destruction" of the arguments to the addition operation. You'll either find what part of your code is broken, find that you can't reproduce this behaviour outside the rest of your code (where there's something broken), or we'll be able to point out what your doing wrong immediately after seeing this program. Of course, all of this assumes that it is in fact not your Java implementation that's broken, but Sun's releases are very unlikely to contain such an obvious violation of the API contract. == 3 of 3 == Date: Wed, Aug 25 2004 5:11 am From: Rogan Dawes <[EMAIL PROTECTED]> Bert Sierra wrote: > OK -- > > Most of the Java API makes sense to me, but there are aspects of the > java.math.BigInteger package that have me stumped. Any help would be > appreciated. > > In one piece of code, I was trying to add two BigIntegers, as follows: > BigInteger a = ...something... > BigInteger b = ...something... > BigInteger c = a.add(b); > > What I quickly discovered was that in some cases the result was returned > by destroying the value in a, and in other cases by destroying the value > in b. I couldn't see a pattern that would explain this behaviour, and > unfortunately in the code I was working with I needed consistent > behaviour. That shouldn't happen. BigIntegers are immutable - that is, it cannot be changed, just like normal Integer, or the other Number classes. > > The Sun API doc was fairly vague, claiming only that add(val) would > return a BigInteger whose value is (this + val) [see > <http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html#add(ja > va.math.BigInteger)>]. It wouldn't explain any side effects of the > addition on the original arguments -- whether the addition would recycle > the objects used, or would result in a new BigInteger being created. Yes, the return value of the various operations is a new BigInteger instance, that holds the result of the operation that was performed. The arguments (a and b) are not modified. > > In the end, I had to augment my code to make copies of the original > BigIntegers prior to the addition, as shown below. I don't like the > fact that I'm creating additional objects, but it's necessary because I > can't figure out how add() [and subtract() and multiply()] operates: > > BigInteger a = ...something... > BigInteger b = ...something... > BigInteger acopy = new BigInteger( a.toByteArray() ); > BigInteger bcopy = new BigInteger( b.toByteArray() ); > BigInteger c = acopy.add(bcopy); > > Seems like an awful lot of work to safely add two integers!! > Seems to me like you are doing something wrong. > TIA for any advice.... Check your code more carefully. You'll surely find your mistake. Rogan -- Rogan Dawes *ALL* messages to [EMAIL PROTECTED] will be dropped, and added to my blacklist. Please respond to "nntp AT dawes DOT za DOT net" ========================================================================== TOPIC: Applets, Security and JVM Support http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b7da802142fe04f7 ========================================================================== == 1 of 2 == Date: Wed, Aug 25 2004 5:51 am From: "SPG" <[EMAIL PROTECTED]> Hi, We currently have a signed applet, which is split into two different branches. The first supports MS JVM, and is compiled to a CAB file, the other supoprts SUN (v 1.4.1 something) and compiled to a JAR. The main problems we have had (and why we split development) is the way the permissions work when checking for permission to make a socket connection. The MS version uses the old chestnut: PolicyEngine.assertPermission(PermissionID.NETIO); To see if we have permissions to make a socket connection. Now, when I try and run the SUN version in anything over 1.4.2 I get permission problems, although the earlier SUN JVMs work. Remember that the JAR file is actually signed. What I need to do is a consolidation of versions so that we have one JAR for all versions (obviously coded for the lowest JVM supported, but working for all). We do not use any third party solutions so it should be just our code that changes. Can anyone shed any light on the permissioning for sockets and signed applets for later versions of JVMs? Steve == 2 of 2 == Date: Wed, Aug 25 2004 7:00 am From: "Mickey Segal" <[EMAIL PROTECTED]> "SPG" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What I need to do is a consolidation of versions so that we have one JAR for > all versions (obviously coded for the lowest JVM supported, but working for > all). We do not use any third party solutions so it should be just our code > that changes. Even if you keep your code at Java 1.1 and use one version of your source code you will need at least two different archive files for a signed applet, CAB for MS JVM and JAR for Sun or Macintosh OS X. In addition, if you want to support Macintosh OS 9 you will need another JAR file, signed with Sun's old signing method. ========================================================================== TOPIC: Using GridBagLayout with JFrame http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6dab24e12aab0546 ========================================================================== == 1 of 1 == Date: Wed, Aug 25 2004 6:16 am From: [EMAIL PROTECTED] (KingKongBundy) Thomas Fritsch <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... Thanks - the inset statements took care of the problem. I wanted to use the GBL for general practice, but the suggestion to use BorderLayout above also worked and was a lot simpler. Besten Dank!! ========================================================================== TOPIC: ArrayList problem http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4063b7309bedf3aa ========================================================================== == 1 of 3 == Date: Wed, Aug 25 2004 6:21 am From: jacov <[EMAIL PROTECTED]> HI, i have a problem with an ArrayList of data: this is a snippet of my problem: //code begin ArrayList data = new ArrayList; Vector _v = returnAVector(); for (int j = 0; j < _v.size(); j++) { data.add(_v.elementAt(j)); } //code end Simple.... The problem is that the arrayList contains only the first element repetead as many times (actually the list size) Any hint is highly welcome Thanks Jacov == 2 of 3 == Date: Wed, Aug 25 2004 6:36 am From: Michael Borgwardt <[EMAIL PROTECTED]> jacov wrote: > HI, i have a problem with an ArrayList of data: this is a snippet of my > problem: > //code begin > ArrayList data = new ArrayList; > Vector _v = returnAVector(); > for (int j = 0; j < _v.size(); j++) { > data.add(_v.elementAt(j)); > } > //code end First, the loop is unnecessary, replace it with data.addAll(_v); But why do you copy the data anyway? If you need an ArrayList, create one directly. Second, the error is not in the code you posted but in the method returnAVector(). Most likely you do not add different objects to the Vecor but instead add the same one many times. == 3 of 3 == Date: Wed, Aug 25 2004 6:48 am From: [EMAIL PROTECTED] On Wed, 25 Aug 2004 15:36:00 +0200, Michael Borgwardt <[EMAIL PROTECTED]> wrote: >jacov wrote: > >> HI, i have a problem with an ArrayList of data: this is a snippet of my >> problem: >> //code begin >> ArrayList data = new ArrayList; >> Vector _v = returnAVector(); >> for (int j = 0; j < _v.size(); j++) { >> data.add(_v.elementAt(j)); >> } >> //code end > >First, the loop is unnecessary, replace it with data.addAll(_v); >But why do you copy the data anyway? If you need an ArrayList, create >one directly. > >Second, the error is not in the code you posted but in the method >returnAVector(). Most likely you do not add different objects to the >Vecor but instead add the same one many times. Yeah, that's my conclusion too. I created this snippet around the sample and (of course) it works fine : //code begin private void test() { ArrayList data = new ArrayList(); Vector _v = returnAVector(); for (int j = 0; j < _v.size(); j++) { data.add(_v.elementAt(j)); } showResults(data); } private Vector returnAVector() { Vector v = new Vector(); v.add("111"); v.add("222"); v.add("333"); return v; } private void showResults(ArrayList a) { for (int j = 0; j < a.size(); j++) { System.err.println("result (" + j + ") : " + a.get(j)); } } //code end Output : result (0) : 111 result (1) : 222 result (2) : 333 ======================================================================= You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer". comp.lang.java.programmer [EMAIL PROTECTED] Change your subscription type & other preferences: * click http://groups-beta.google.com/group/comp.lang.java.programmer/prefs Report abuse: * send email explaining the problem to [EMAIL PROTECTED] Unsubscribe: * click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe ======================================================================= Google Groups: http://groups-beta.google.com ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/BCfwlB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/kumpulan/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/