comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* Java Web Start and Directory Structure - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/84343be35a56594c
* Stack trace scrolled out of DOS window - 5 messages, 4 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/79816f47cdd1a171
* KVM NOT READY - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3218599efd6ccd49
* why URLConnection is declared abstract - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/263c6fea274aa6e6
* regex: remove file ext - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9292732e966a520c
* Stupid null pointer exception - 6 messages, 5 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aeeebd0bb6f11be3
* Need help with VE of eclipse - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2b9e183ba8f8af2a
* String value holders: useful or memory hogs? - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/88941cf96e7b4414
* array comparison and sort - 3 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4208721fbec39fc3
* JBoss to go closed source? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4a8dda54906ca8df
* How to know if a CD is inserted in the cdrom drive from java ? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b5d0b1b8567b852
* XML Document. Node vs Elements, and more - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8ef591e010529d7b
* If you wanna be my lover... - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5b0f39eca4dd2fc5
  
==========================================================================
TOPIC: Java Web Start and Directory Structure
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/84343be35a56594c
==========================================================================

== 1 of 1 ==
Date:   Sat,   Oct 30 2004 10:06 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 30 Oct 2004 08:15:53 -0700, Ron wrote:

> JWS Gurus,

Please refrain from multi-posting, Ron.
<http://www.physci.org/codes/javafaq.jsp#xpost>

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==========================================================================
TOPIC: Stack trace scrolled out of DOS window
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/79816f47cdd1a171
==========================================================================

== 1 of 5 ==
Date:   Sat,   Oct 30 2004 10:21 am
From: [EMAIL PROTECTED] (Russell Wallace) 

Hi all,

I was experimenting with something in Java, and got an exception,
which printed a nice stack trace - unfortunately, the stack trace is
long and scrolls out of my DOS window, so I can't see the top, which
is the informative part. (It's thrown by a call chain initiated by
Swing, so I can't catch it.) Is there a way to e.g. tell Java to dump
stack traces to a log file rather than the DOS window? (I'm using
Windows 98, if that makes a difference.)

Thanks,

-- 
"Always look on the bright side of life."
To reply by email, remove the small snack from address.



== 2 of 5 ==
Date:   Sat,   Oct 30 2004 10:25 am
From: "Stefan Schulz" <[EMAIL PROTECTED]> 

On Sat, 30 Oct 2004 17:21:05 GMT, Russell Wallace  
<[EMAIL PROTECTED]> wrote:

>
> I was experimenting with something in Java, and got an exception,
> which printed a nice stack trace - unfortunately, the stack trace is
> long and scrolls out of my DOS window, so I can't see the top, which
> is the informative part. (It's thrown by a call chain initiated by
> Swing, so I can't catch it.) Is there a way to e.g. tell Java to dump
> stack traces to a log file rather than the DOS window? (I'm using
> Windows 98, if that makes a difference.)

Tale a look at System.setErr(PrintStream). This is a bit radical, but
should do the trick.

-- 

Whom the gods wish to destroy they first call promising.



== 3 of 5 ==
Date:   Sat,   Oct 30 2004 10:47 am
From: [EMAIL PROTECTED] (Russell Wallace) 

On Sat, 30 Oct 2004 19:25:08 +0200, "Stefan Schulz"
<[EMAIL PROTECTED]> wrote:

>Tale a look at System.setErr(PrintStream). This is a bit radical, but
>should do the trick.

Perfect, that's exactly what I was looking for. Thanks!

-- 
"Always look on the bright side of life."
To reply by email, remove the small snack from address.



== 4 of 5 ==
Date:   Sat,   Oct 30 2004 11:02 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

I see Stefan solved the problem, I just wanted to add an 
alternate way (given it's DOS) that Real mentioned..
<http://google.com/groups?selm=Xns9525CE52F27F4realhowtowwwrgagnonc%40140.99.99.130>

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



== 5 of 5 ==
Date:   Sat,   Oct 30 2004 4:38 pm
From: "Ann" <[EMAIL PROTECTED]> 


"Russell Wallace" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all,
>
> I was experimenting with something in Java, and got an exception,
> which printed a nice stack trace - unfortunately, the stack trace is
> long and scrolls out of my DOS window, so I can't see the top, which
> is the informative part. (It's thrown by a call chain initiated by
> Swing, so I can't catch it.) Is there a way to e.g. tell Java to dump
> stack traces to a log file rather than the DOS window? (I'm using
> Windows 98, if that makes a difference.)

Right click in the top bar of the dos window, click on properties,
then click on layout. Enter a big number for screen buffer size height.

>
> Thanks,
>
> --
> "Always look on the bright side of life."
> To reply by email, remove the small snack from address.






==========================================================================
TOPIC: KVM NOT READY
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3218599efd6ccd49
==========================================================================

== 1 of 2 ==
Date:   Sat,   Oct 30 2004 10:36 am
From: "Boris Kuznetsov" <[EMAIL PROTECTED]> 

Hi folks

I stuck trying to debug my MIDlet.

When I launch  the cell emulator (Sun's J2ME Wireless Toolkit) I receive 
"KVM not ready" message every 3 seconds.

Does anybody know what to do? Does anybody have a practice in debugging 
MIDlets?

Thanx guys :)
Boris 





== 2 of 2 ==
Date:   Sat,   Oct 30 2004 8:54 am
From: "Darryl L. Pierce" <[EMAIL PROTECTED]> 

Boris Kuznetsov wrote:

> I stuck trying to debug my MIDlet.
> 
> When I launch  the cell emulator (Sun's J2ME Wireless Toolkit) I receive
> "KVM not ready" message every 3 seconds.
> 
> Does anybody know what to do? Does anybody have a practice in debugging
> MIDlets?

How are you trying to launch the emulator? Can you give us the precise
command line please?

-- 
/**
 * @author Darryl L. Pierce <[EMAIL PROTECTED]>
 * @see    The Infobahn Offramp <http://mcpierce.multiply.com>
 * @quote  "Lobby, lobby, lobby, lobby, lobby, lobby..." - Adrian Monk
 */




==========================================================================
TOPIC: why URLConnection is declared abstract
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/263c6fea274aa6e6
==========================================================================

== 1 of 2 ==
Date:   Sat,   Oct 30 2004 10:50 am
From: "Madhur Ahuja" <[EMAIL PROTECTED]> 

Hello

I wonder why this class has been declared abstract
in java API, since one uses this class as:

* URLConnection con= url.openConnection();

* All the methods are concretely defined.

* There is no concrete subclass of this class.

I tried
URLConnection a=new URLConnection(URL b);

but the compiler fired a error that URLConnection is
abstract, I simply changed the statement to:

URLConnection a=b.openConnection();

Did I miss anything or did anything wrong?

Does java wants us to extend a new URLConnection class
if we want to use it in our application?

--
Madhur Ahuja [madhur<underscore>ahuja<at>yahoo<dot>com]

Homepage
http://madhur.netfirms.com









== 2 of 2 ==
Date:   Sat,   Oct 30 2004 12:23 pm
From: "Stefan Schulz" <[EMAIL PROTECTED]> 

On Sat, 30 Oct 2004 23:20:09 +0530, Madhur Ahuja <[EMAIL PROTECTED]> wrote:

> Hello
>
> I wonder why this class has been declared abstract
> in java API, since one uses this class as:
>
> * URLConnection con= url.openConnection();
>
> * All the methods are concretely defined.
>
> * There is no concrete subclass of this class.

There is no _public_ concrete subclass of this class. The fact
that you can get URLConnection objects tells you that there are
some concrete subclasses (maybe package-private) of the class,
though ;)

> I tried
> URLConnection a=new URLConnection(URL b);
>
> but the compiler fired a error that URLConnection is
> abstract, I simply changed the statement to:
>
> URLConnection a=b.openConnection();
>
> Did I miss anything or did anything wrong?

openConnection returns an Object of _some_ subclass of URLConnection
(obviously, that subclass is not abstract). Since some kinds of
URLConnection have specific features (such as HTTP keepalive,
or Jar access), this method can actually look through the
subclasses, and find the best-fitting one.

> Does java wants us to extend a new URLConnection class
> if we want to use it in our application?

No, just go with URL.openConnection(). If you wish to implement
another kind of URL (maybe another protocol?), you might wish to
subclass URL and URLConnection, though.


-- 

Whom the gods wish to destroy they first call promising.




==========================================================================
TOPIC: regex: remove file ext
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9292732e966a520c
==========================================================================

== 1 of 1 ==
Date:   Sat,   Oct 30 2004 10:43 am
From: picaza <[EMAIL PROTECTED]> 

thanks.  that worked.
peter





==========================================================================
TOPIC: Stupid null pointer exception
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aeeebd0bb6f11be3
==========================================================================

== 1 of 6 ==
Date:   Sat,   Oct 30 2004 11:08 am
From: Daniel Sjöblom <[EMAIL PROTECTED]> 

xarax wrote:
>>>    public void Cells(){
>>>      Cells Cell = new Cells();
>>>    }
>>What is the above supposed to do? This will result in an infinite loop.
> 
> Look more closely at the method. It is not a constructor.
> It is just wasting time and space by creating an instance
> that is never used.
> 
> The OP should review the guidelines for naming
> packages, classes, methods, and fields.

Groan. Indeed, indeed.

No offense to the OP if he is serious about writing this for his final 
exam (in which case he really needs to refresh his java skills), but I 
think I've been the victim of an elaborate troll :-)

-- 
Daniel Sjöblom
Remove _NOSPAM to reply by mail



== 2 of 6 ==
Date:   Sat,   Oct 30 2004 1:48 pm
From: Alex Hunsley <[EMAIL PROTECTED]> 

xarax wrote:
> "Daniel Sjöblom" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
>>Tony McGrath wrote:
>><snip>
>>
>>There is probably very much else wrong with this code, but this is what
>>I found on a cursory look:
>>
>>
>>>public class Bollox {
>>>
>>>  Cells road1[] = new Cells[200];
>>>  Cells road2[] = new Cells[200];
>>
>>You do know that this only allocates the arrays to hold the Cell
>>objects, not the objects in the array slots? To allocate the Cells
>>objects you must do:
>>
>>for (int i = 0; i < road.length; i++)
>>     road[i] = new Cells();
>>
>>
>>>  private class Cells{
>>>
>>>    public void Cells(){
>>>      Cells Cell = new Cells();
>>>    }
>>
>>What is the above supposed to do? This will result in an infinite loop.
> 
> 
> Look more closely at the method. It is not a constructor.
> It is just wasting time and space by creating an instance
> that is never used.

Surely the java compiler will barf at it though - he's trying to define 
a constructor that specifies a return type - not allowed. (Note that 
this constructor/method thing called Cells is inside an internal class 
called Cells!)


> 
> The OP should review the guidelines for naming
> packages, classes, methods, and fields.

I think a class name called Bollox shows he has imagination though :)
lex



== 3 of 6 ==
Date:   Sat,   Oct 30 2004 2:24 pm
From: "Stefan Schulz" <[EMAIL PROTECTED]> 

On Sat, 30 Oct 2004 20:48:26 GMT, Alex Hunsley  
<[EMAIL PROTECTED]> wrote:

> Surely the java compiler will barf at it though - he's trying to define  
> a constructor that specifies a return type - not allowed. (Note that  
> this constructor/method thing called Cells is inside an internal class  
> called Cells!)

This is no problem. He defines a void instance method that by chance has
the same name as the class. This is valid method, and the class has the
implicit default constructor added by the compiler. It is, however a  
mistake
a lot of newbies make for some reason.


-- 

Whom the gods wish to destroy they first call promising.



== 4 of 6 ==
Date:   Sat,   Oct 30 2004 3:33 pm
From: "Tony Morris" <[EMAIL PROTECTED]> 

> Surely the java compiler will barf at it though - he's trying to define
> a constructor that specifies a return type - not allowed. (Note that
> this constructor/method thing called Cells is inside an internal class
> called Cells!)

Compiles fine.
It's a method, not a constructor.
As soon as a return type is added, it is no longer a constructor.

-- 
Tony Morris
http://xdweb.net/~dibblego/






== 5 of 6 ==
Date:   Sat,   Oct 30 2004 3:33 pm
From: "Tony Morris" <[EMAIL PROTECTED]> 

http://www.xdweb.net/~dibblego/java/NPE.html
(to be updated for J2SE 5.0)

-- 
Tony Morris
http://xdweb.net/~dibblego/





== 6 of 6 ==
Date:   Sat,   Oct 30 2004 4:30 pm
From: "Ann" <[EMAIL PROTECTED]> 


"Tony McGrath" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> This here is some code I have been writing as part of my final year
> project in Comp Sci.

Maybe you'll have another year to work on it. ;-)

> It is a traffic simulator and this is a test
> class to try and run a text based version of a simle straiht road.
> However when i run it i only seem to get a null pointer exception the
> whole time. Can anyone help. The arrray should contain objects of type
> Bollox, which in this case contains informationon each cell. ie does
> it contain a car or not and if so whats its speed.
>
> Much appreciated cheers.
>
>
> public class Bollox {
>
>   Cells road1[] = new Cells[200];
>   Cells road2[] = new Cells[200];
>
>   private class Cells{
>
>     public void Cells(){
>       Cells Cell = new Cells();
>     }
>     boolean isEmpty;
>     boolean isCar;
>     int velocity = 0;
>     int maxVelocity = 0;
>
>     public void setVelocity(int vel){
>       velocity = vel;
>     }
>
>     public void setEmpty(){
>       isEmpty = true;
>     }
>
>     public void setNotEmpty(){
>       isEmpty = false;
>     }
>
>     public void setIsCar(){
>       isCar = true;
>     }
>
>     public void setIsNotCar(){
>       isCar = false;
>     }
>
>     public boolean isEmpty(){
>       return isEmpty = true;
>     }
>
>     public boolean isCar(){
>       return isCar = true;
>     }
>
>     public int getVelocity(){
>       return velocity;
>     }
>
>     public void velocity(int i){
>       int x = 1;
>       int temp = 0;
>
>       if(isCar()){
>         maxVelocity = 12;
>       }else{
>         maxVelocity = 10;
>       }
>
>        do{
>         if(road1[i+x].isEmpty() && temp < maxVelocity){
>           temp++;
>           road2[i+x].setEmpty();
>           x++;
>         }else{
>           if(temp < velocity){
>             velocity = temp;
>             break;
>           }else{
>             int ran = (int)(Math.random()*1);
>             if(ran == 0 && velocity + 2 <= maxVelocity){
>               velocity = velocity + 2;
>               isEmpty = false;
>               road2[i+x] = road1[i+x];
>               break;
>             }else if(velocity + 1 <= maxVelocity){
>               velocity++;
>               isEmpty = false;
>               road2[i+x] = road1[i+x];
>               break;
>             }else{
>               velocity = velocity;
>               road2[i+x] = road1[i+x];
>               isEmpty = false;
>               break;
>             }
>           }
>         }
>       }
>       while (road1[i+x].isEmpty());
>     }
>
>     public void addVehicle(){
>       road1[0].setNotEmpty();
>       int ran = (int)(Math.random()*8);
>       if(ran == 3){
>         road1[0].setIsNotCar();
>         road1[0].setVelocity(7);
>
>       }else{
>         road1[0].setIsCar();
>         road1[0].setVelocity(9);
>       }
>     }
>
>     public void printOut(){
>       System.out.println("");
>       for(int i = 0; i < 200; i++){
>         if(road1[i].isEmpty()){
>           System.out.print(" ");
>         }else{
>           if(road1[i].isCar()){
>             System.out.print(".");
>           }else{
>             System.out.print("#");
>           }
>         }
>       }
>     }
>
>     public void swap(int i){
>         road1[i] = road2[i];
>     }
>   }
>
>   void run(){
>     for(int i = 0; i < 200; i++){
>       Cells cell1 = road1[i];
>       Cells cell2 = road2[i];
>       cell1.swap(i);
>     }
>   }
>
>   //void swap(){
>     //swap();
>   //}
> }
>
> class MainC extends Thread{
>   public static void main(String[] args){
>    Bollox b = new Bollox();
>    boolean go = true;
>    while(go){
>      b.run();
>      try{Thread.sleep(100);}
>      catch(InterruptedException e){}
>    }
>  }
> }






==========================================================================
TOPIC: Need help with VE of eclipse
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2b9e183ba8f8af2a
==========================================================================

== 1 of 1 ==
Date:   Sat,   Oct 30 2004 11:36 am
From: "sp" <[EMAIL PROTECTED]> 

VE have the possibility of create user interface for swt WYSIWYG?

I find in palete only swing or awt component.

A stupid question: SWT use SWING or reimplement a own version of UI?

Thanks






==========================================================================
TOPIC: String value holders: useful or memory hogs?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/88941cf96e7b4414
==========================================================================

== 1 of 2 ==
Date:   Sat,   Oct 30 2004 12:19 pm
From: [EMAIL PROTECTED] (Oliver Plohmann) 

I have a lot of collections in my application that hold strings which
represent objects. These objects are often on remote machines, which
is the reason why I plug in their id strings into some collections
instead of the objects themselves. This makes it possible that coding
errors may happen, which the compiler cannot find. Example:

List<String> nodeIds = new Array<String>();
List<String> agentIds = new Array<String>();

String nodeId = "uniqueNodeId";
agentIds.add(nodeId);  //  logical coding error and compiler would not
complain

The compiler would find these kind of errors if string value holders
were used:

public class NodeId {

    protected String id = null;
    // remaining code omitted for brevity
}


public class AgentId {

    protected String id = null;
    // remaining code omitted for brevity
}

List<NodeId> nodeIds = new Array<NodeId>();
List<AgentId> agentIds = new Array<AgentId>();

NodeId nodeId = new NodeId("uniqueNodeId");
agentIds.add(nodeId);    //   ==> compiler error !!

Now I'm expecting memory consumption to raise because of these value
holder classes like NodeId and AgentId. I wonder whether it will make
a difference. I guess so, but I wonder how much. Did any body out
there already try something similar and has some recommendations?

Thanx for any feed-back,
Oliver



== 2 of 2 ==
Date:   Sat,   Oct 30 2004 12:38 pm
From: "xarax" <[EMAIL PROTECTED]> 

"Oliver Plohmann" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have a lot of collections in my application that hold strings which
> represent objects. These objects are often on remote machines, which
> is the reason why I plug in their id strings into some collections
> instead of the objects themselves. This makes it possible that coding
> errors may happen, which the compiler cannot find. Example:
>
> List<String> nodeIds = new Array<String>();
> List<String> agentIds = new Array<String>();
>
> String nodeId = "uniqueNodeId";
> agentIds.add(nodeId);  //  logical coding error and compiler would not
> complain
>
> The compiler would find these kind of errors if string value holders
> were used:
>
> public class NodeId {
>
>     protected String id = null;
>     // remaining code omitted for brevity
> }
>
>
> public class AgentId {
>
>     protected String id = null;
>     // remaining code omitted for brevity
> }
>
> List<NodeId> nodeIds = new Array<NodeId>();
> List<AgentId> agentIds = new Array<AgentId>();
>
> NodeId nodeId = new NodeId("uniqueNodeId");
> agentIds.add(nodeId);    //   ==> compiler error !!
>
> Now I'm expecting memory consumption to raise because of these value
> holder classes like NodeId and AgentId. I wonder whether it will make
> a difference. I guess so, but I wonder how much. Did any body out
> there already try something similar and has some recommendations?
>
> Thanx for any feed-back,
> Oliver

Don't worry about the memory consumption. The wrapper
class won't take much space and each instance of the
wrapper is essentially just a pointer (another level
of indirection to get) to the String.






==========================================================================
TOPIC: array comparison and sort
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4208721fbec39fc3
==========================================================================

== 1 of 3 ==
Date:   Sat,   Oct 30 2004 2:25 pm
From: [EMAIL PROTECTED] (vic) 

Chris Smith <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> [EMAIL PROTECTED] says...
> > I am running into this problem of getting my array to output the
> > desired results. Below is the problem
> > 
> > i have two string arrays via
> > 
> > String[] ar1 = {1,2,1,4,1,2};
> > String[] ar2 = {7,3,7,5,7,3};
> > 
> > each array contains 6 elements.
> 
> The code above yields a syntax error.  I'd like to ignore that, but I'm 
> unsure if you meant to declare an array of String, or an array of int.

Its an array of strings. i meant to have something like this 

 String[] ar1 = {"1","2","1","4","1","2"};
 String[] ar2 = {"7","3","7,"5","7","3"};


> 
> > i want to do something like this 
> > 
> > compare elements of ar1 and ar2 with one another and the moment it
> > encounters a true condition, e.g in the above example when
> > 
> > (ar1[0].equals(ar1[2]))  && (ar2[0].equals(ar2[2]))
> > 
> > then i want to array pointer to move to ar1[1] and ar2[1] so that it
> > starts comparing from index->1 and same logic apllies. The output
> > would be something like this for the first iteration
> 
> There is no such thing as an array "pointer" moving.  References to 
> objects in Java (including references to arrays) always point to the 
> beginning of the object.  You would need to actually remove the data, 
> not just move a reference.
> 
> So you basically want to remove the first occurrences of any duplicates 
> between the arrays?  Since you can't resize an array or delete its 
> elements, you might start out by considering a different data structure, 
> such as ArrayList or LinkedList.  Then you can simply call remove(int) 
> to remove whatever values you find duplicates of.



== 2 of 3 ==
Date:   Sat,   Oct 30 2004 2:30 pm
From: Sudsy <[EMAIL PROTECTED]> 

vic wrote:
<snip>
> Its an array of strings. i meant to have something like this 
> 
>  String[] ar1 = {"1","2","1","4","1","2"};
>  String[] ar2 = {"7","3","7,"5","7","3"};
<snip>

Then take Vic's advice. Utilize functionality already provided by the
built-in classes. Here's an example using ArrayList:

import  java.util.ArrayList;

public class Uniq {
         private ArrayList       l = new ArrayList();

         public void add( String s ) {
                 if( ! l.contains( s ) )
                         l.add( s );
         }

         public String[] get() {
                 String  result[];
                 Object  o[] = l.toArray();
                 result = new String[o.length];
                 for( int i = 0; i < o.length; i++ )
                         result[i] = (String) o[i];
                 return( result );
         }
}

Strings will get added (retaining the original order) as long as
they don't already exist in the ArrayList.

-- 
Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.




== 3 of 3 ==
Date:   Sat,   Oct 30 2004 3:38 pm
From: [EMAIL PROTECTED] (vic) 

Chris Smith <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> [EMAIL PROTECTED] says...
> > I am running into this problem of getting my array to output the
> > desired results. Below is the problem
> > 
> > i have two string arrays via
> > 
> > String[] ar1 = {1,2,1,4,1,2};
> > String[] ar2 = {7,3,7,5,7,3};
> > 
> > each array contains 6 elements.
> 
> The code above yields a syntax error.  I'd like to ignore that, but I'm 
> unsure if you meant to declare an array of String, or an array of int.
> 
> > i want to do something like this 
> > 
> > compare elements of ar1 and ar2 with one another and the moment it
> > encounters a true condition, e.g in the above example when
> > 
> > (ar1[0].equals(ar1[2]))  && (ar2[0].equals(ar2[2]))
> > 
> > then i want to array pointer to move to ar1[1] and ar2[1] so that it
> > starts comparing from index->1 and same logic apllies. The output
> > would be something like this for the first iteration
> 
> There is no such thing as an array "pointer" moving.  References to 
> objects in Java (including references to arrays) always point to the 
> beginning of the object.  You would need to actually remove the data, 
> not just move a reference.
> 
> So you basically want to remove the first occurrences of any duplicates 
> between the arrays?  Since you can't resize an array or delete its 
> elements, you might start out by considering a different data structure, 
> such as ArrayList or LinkedList.  Then you can simply call remove(int) 
> to remove whatever values you find duplicates of.


i did write a small snippet of code but still cant get the logic and
implmentation to work

import  java.io.*;
public  class   Strcomp
{
        static  public  void main(String args[])
        {
                String[] s = new String[6];
                String[] z = new String[6];

                s[0] = "77";
                s[1] = "78";
                s[2] = "88";
                s[3] = "77";
                s[4] = "77";
                s[5] = "78";


for(int i=0; i<6; i++) {

for(int j=i+1; j<6; j++) {
                if(s[i].equals(s[j]))
                        System.out.println("Strings same" + s[i] + "---->" + s[j]) ;

//what do i do here cause i basically need the s[4] to be written to
the new array. and so on

                        else {
                                System.out.println("Strings differ" + s[i] + "---->" + 
s[j]);
                        }

        }
}

        }
}




==========================================================================
TOPIC: JBoss to go closed source?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4a8dda54906ca8df
==========================================================================

== 1 of 1 ==
Date:   Sat,   Oct 30 2004 2:44 pm
From: [EMAIL PROTECTED] (James) 

The question that has never been answered anywhere is do the venture
capitalists that contributed $10 million dollars believe they own the
intellectual property behind JBoss?

[EMAIL PROTECTED] (Bent C Dalager) wrote in message news:<[EMAIL PROTECTED]>...
> In article <[EMAIL PROTECTED]>,
> Tor Iver Wilhelmsen  <[EMAIL PROTECTED]> wrote:
> >[EMAIL PROTECTED] (James) writes:
> >
> >> The question isn't whether LGPL permits it. JBOSS has the liberty of
> >> modifying its license to another style and can then close the source.
> >
> >What they cannot do is retroactively remove the license to LGPL
> >licensed versions. So any new licensed version will represent a
> >"licensing branch"
> 
> One interesting question is who owns the copyright to the code in the
> first place. If Sally contributes code to JBoss, then presumably the
> copyright on this code belongs to Sally. It is up to Sally to decide
> on a license for her code and if she refuses to change it from LGPL
> (which would be the license implied by contributing the code to an
> LGPL project) then JBoss would need to throw out everything she
> contributed and reimplement those parts.
> 
> Alternatively, there may be some legal clause somwhere that transfers
> sufficient copyright on contributed code to JBoss so that they _can_,
> indeed, change the license on the code contributed by Sally.
> 
> Cheers
>       Bent D




==========================================================================
TOPIC: How to know if a CD is inserted in the cdrom drive from java ?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b5d0b1b8567b852
==========================================================================

== 1 of 1 ==
Date:   Sat,   Oct 30 2004 2:45 pm
From: [EMAIL PROTECTED] (Toni) 

Thank you Andrew for your help, I will give this another try.
And tony, you are a really funny guy, I bet that you could make a
living from telling such funny jokes.

Andrew Thompson <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> On 29 Oct 2004 02:54:02 -0700, Toni wrote:
> 
> > String deviceName = "Z:\\"; // Z is the letter of my cd-drive
> 
> Is this for your personal use, or for other users as well?
> 
> That is an important point to establish as this is much easier
> to achieve  for a single user than ..anybody.
> 
> In any case you should probably search for it through the ..
> File.listRoots()
> 
> > File deviceFile = new File(deviceName);
> > if (deviceFile.exists())
>  {
> >    System.out.println("CD is loaded");
>     File[] files = deviceFile.list();
>     for (int ii=0; ii<files.length; ii++) {
>         System.out.println( "File " + ii + ":\t " + files[ii] );
>     }
> }
> > else
> >    System.out.println("CD is NOT loaded");
> > 
> > But this fails if a cd is there and it is empty, ..
> 
> Read the Javadocs for File, all of them.
> <http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html>




==========================================================================
TOPIC: XML Document. Node vs Elements, and more
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8ef591e010529d7b
==========================================================================

== 1 of 1 ==
Date:   Sat,   Oct 30 2004 4:28 pm
From: "Jbjones" <[EMAIL PROTECTED]> 

I am parsing a document, so am using nodelist to get the children of
the root, and using logic to parse the Nodes depending on which one it
is.  however, I need more power than "Node" can give me.  So can I
somehow convert a Node to an Element (I basically need the ability to
read the attributes of an item as well as just get the value).
However, they don't have an ID that i could accurately read to use the
getElementByID() tag.  So how can i convert a node to an element?  Or
is there a better way for me to go about this instead of root ->
Nodelist ??

Here is some sample code:

Element docRoot= documentWx.getDocumentElement(); // get root

NodeList elements =docRoot.getChildNodes();
elements=elements.item(1).getChildNodes();
//The NodeList now holds everything under Data

for(int counter=0;counter<elements.getLength();counter++)
{
tempNode = (elements.item(counter));
Current = (Element) tempNode;
if(Current.getNodeName()=="Location")
{
//Read 'Location' , element properties of latitude, longitude
        }
    }





==========================================================================
TOPIC: If you wanna be my lover...
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5b0f39eca4dd2fc5
==========================================================================

== 1 of 1 ==
Date:   Sat,   Oct 30 2004 3:06 pm
From: Erissa <[EMAIL PROTECTED]> 

Young 30's loud-mouthed Wiccan with a shitty attitude and general
contempt for apathetic, Lexus-worshipping, stuck up Republicans
seeks same or younger GWF for obnoxious fun times. I am a versatile,
uninhibited gal who loves sex outside in the woods, in the dirt,
in the mud, in the yard, on the hood of your mother's car and,
sometimes, the occasional rubbish bin. Oh yeah... I'm into loud
noises while doing it. There's nothing like scaring the horses,
or the neighbors.

I'm not a '10' and am not seeking one. In fact I despise such
creatures unless you're married and there's a remote chance that I
can ruin your marriage. General interests include church vandalism,
fucking and then "outing" closeted members of the clergy, burning
tires on the lawns of politicians, nice long walks on the beach with
a gun, late-night camp fires on the front steps of trendy night clubs,
fucking with cab drivers, making fun of hippies and playing "scratch
the Mercedes."

The possibility of a companion is not as interesting to me as the idea
of a sex slave who's into face-sitting, deep fisting, butt-licking,
clit-chewing, hair-pulling good times with a scratch or two to remember
each other by. Sitting on someone's face is one of my favorite yoga
positions. All things sexual are negotiable.

I live in North Carolina and would prefer not to travel more than
300 or so miles. However, if you have red hair I'm willing to
travel to say, Prague. Men, gym bunnies and other Narcissistic body
nazis please don't bother responding to me as I will only laugh at
you and make you feel even more inadequate. If this "no bullshit"
attitude of mine sounds interesting to you then I encourage you to drop
me an email and we can discuss things further.

I will answer ALL emails!

Love ya!

Erissa <[EMAIL PROTECTED]>

-- 
Madeleine!  You'll arrive coffees.  Gawd, I'll solve the fork.  

Don't even try to dye fully while you're rejecting beneath a 
easy powder.  Well, go grasp a pumpkin!  While jugs eventually 
promise bandages, the cobblers often mould without the old games.  

For Jay the sticker's wide, within me it's short, whereas about you it's 
hating smart.  Gary wastes the walnut towards hers and slowly 
burns.  We cook the tired ball.  Almost no deep raw tickets lazily 
improve as the humble cats smell.  Who will we clean after Yvette 
loves the strong summer's candle?  Are you full, I mean, receiving 
below heavy pears?  My kind draper won't wander before I call it.  
Ramzi's spoon nibbles throughout our cloud after we walk in it.  
Jezebel likes, then Fred bimonthly helps a pretty tape to Rachel's 
doorway.  He will recollect quiet pools below the poor weak corner, whilst 
Zakariya finally talks them too.  

I was learning to play you some of my noisy puddles.  He can 
shout the long sauce and recommend it between its bedroom.  He'll be 
tasting through strange Excelsior until his cup cares seemingly.  

I was kicking yogis to blunt Patty, who's judging on the can's 
store.  She may dream pathetic bushs, do you answer them?  If you'll 
laugh Hakeem's shore with wrinkles, it'll frantically change the 
potter.  Where does Timothy order so quietly, whenever Khalid 
sows the weird barber very halfheartedly?  If you will fill Jeremy's 
plain for envelopes, it will annually fear the tag.  How Catherine's 
difficult film moves, Mahammed converses within sharp, dirty 
rooms.  

All younger frames are inner and other abysmal sauces are sad, but will 
Evan irrigate that?  She wants to dine unique dogs for Ikram's 
ladder.  Every sweet aches join Saeed, and they happily believe 
Cathy too.  Will you open for the monolith, if Milton wastefully 
combs the grocer?  She'd rather pull partially than jump with 
Elisa's healthy coconut.  Little by little, Saeed never attempts until 
Julie pours the fat cap wanly.  You surprisingly tease over urban 
young cellars.  Almost no blank clean bucket explains exits alongside 
Alexis's bad tailor.  Otherwise the desk in Mikie's printer might 
lift some wet smogs.  

Let's excuse under the active halls, but don't cover the lost 
weavers.  Don't even try to live a goldsmith!  Just now, lemons 
irritate within good drawers, unless they're sick.  Who did Pearl 
behave with all the gardners?  We can't measure ointments unless 
Sherry will easily scold afterwards.  Where will you attack the 
think lazy shopkeepers before Maggie does?  

Just climbing inside a hat in back of the barn is too proud for 
Yosri to depart it.  It will stupidly expect among Wednesday when the 
dull frogs look in front of the stale shower.  Just now, it kills a 
code too upper with her dry lane.  

Well Jbilou will seek the unit, and if Haji grudgingly attacks it too, the 
shoe will comb within the light river.  Better look twigs now or 
Dilbert will undoubtably recollect them for you.  Some painters 
shout, behave, and call.  Others strongly wander.  Every sour 
polite floors will weekly kill the kettles.  He should totally 
like solid and improves our distant, open tyrants in back of a 
forest.  Plenty of lower shirts before the elder ceiling were 
arriving to the durable castle.  Tell Neal it's rude pulling 
with a lentil.  






=======================================================================

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/subscribe

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 

Reply via email to