comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * A question of reading api document - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1c6d046830d875c * object problem? - 6 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1bd7ea0d3b158f73 * SOLD GOOG bought BE - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/662b70234da635f3 * Http server question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fe0bdc9ae6fb0c60 * JSP/Servlets J2EE - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bb75a63dcb4eb0db * Using <jsp:getProperty> within rtexprvalue Attributes - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/83818b0ae9771445 * references and a binary tree - 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d897505b2c28f461 * Microsoft to make Visual Studio Open Source - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/76bb971914b255fe * Environment variable - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e10a85f420f52962 * 2 interface with 2 same function prototype but different return type - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5277abed8de68298 * limitations of Java VM under Windows/Linux? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc3538556e5ad6cd * Using com.sun.tools.javac.Main() for compiling - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/894f2738d346f374 * How 'java' (command) handles the classname passed - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/908d4e10411ee318 ========================================================================== TOPIC: A question of reading api document http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1c6d046830d875c ========================================================================== == 1 of 3 == Date: Sun, Nov 21 2004 5:10 am From: [EMAIL PROTECTED] (mike) regards: When I read the api of some opensource Classes XXX.YYY -------------------------- What is the relation between YYY and XXX? Is YYY XXX's inner class? --------------------------- Thank you. May god be with you. == 2 of 3 == Date: Sun, Nov 21 2004 5:34 am From: Andrew Thompson <[EMAIL PROTECTED]> On 21 Nov 2004 05:10:38 -0800, mike wrote: > When I read the api of some opensource What OpenSource? > Classes > XXX.YYY What's that mean? Is that supposed to be a package statement? If that's the case, what package is made of an acronym of three words all beginning with the letter 'x'? [ The hidden message here is 'Please be more specific' <http://www.physci.org/codes/javafaq.jsp#specific> ] -- 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 == 3 of 3 == Date: Sun, Nov 21 2004 5:36 am From: Davide <[EMAIL PROTECTED]> mike wrote: > regards: > > > When I read the api of some opensource > > > Classes > XXX.YYY > -------------------------- > What is the relation between YYY and XXX? > > Is YYY XXX's inner class? > > > --------------------------- > Thank you. > May god be with you. Hi Mike. Perhaps I may be wrong... could be XXX a class in YYY package? For example, you could have ZZZ.XXX.YYY, this may be java.util.Vector: java is the external package, util is the inner package ad Vector a class in java.util package. This could be true if YYY start whit capital letter and XXX doesn't. If you post exact names it could simpler to identify XXX and YYY roles ;) Sorry for my bad english :) Bye, Davide ========================================================================== TOPIC: object problem? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1bd7ea0d3b158f73 ========================================================================== == 1 of 6 == Date: Sun, Nov 21 2004 5:25 am From: Andrew Thompson <[EMAIL PROTECTED]> On Sun, 21 Nov 2004 14:00:29 +0100, KiLVaiDeN wrote: > "Andrew Thompson" <[EMAIL PROTECTED]> wrote in message ... >> I suggest you include, >> - an SSCCE <http://www.physci.org/codes/sscce.jsp> ... >> -- >> 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 [1] > Andrew : why do you always .. [2] > ..have to .. [3] > ..post links to your website ? [2] I do not always post links. Only where I feel they are relevant. When I post links, I post links to the best information available irrespective of the source. It just happens that most of the best sources of information (on questions I feel qualified to comment upon) are on my site. They are on my site because I put them there, just to save typing the answers again (and again and again..). [3] I do not have to, I do do it as a service to the Java developer community in general, and these forums in particular. [1] Unless you are referring to my sig., which you failed to edit from your reply, so maybe this is a good time to point out.. <http://www.physci.org/codes/javafaq.jsp#netiquette>, (note last two paragraphs) unless you were indeed making reference to my sig., in which case.. <http://www.physci.org/codes/javafaq.jsp#specific> >..is it only for the hits? ? (shrugs) What's that mean? I am the only one that knows how many hits I have, and even then I am not entirely clear on how to read the server stats. I also have Google and other advertising on my sites. All the 'click-thru' ads for which I get paid end up covering about one third of the cost of the server. I would remove them and recalim my precious screen acreage except for the fact that Google indexes my pages sooooo fast. [ ;-) ] > Was just wondering :) Am just answering. -- 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 == 2 of 6 == Date: Sun, Nov 21 2004 6:42 am From: Joona I Palaste <[EMAIL PROTECTED]> nick <[EMAIL PROTECTED]> scribbled the following: > Player temp; > temp=currentPlayer; > currentPlayer=nextPlayer; > nextPlayer=temp; > >> temp=currentPlayer; > is temp become a reference address of currentPlayer in there? When the second line has been executed, yes, both variables temp and currentPlayer refer to the same object. > how to copy a new object to temp? Strictly speaking, you can't. Java variables don't hold objects, they hold references to objects. If you mean "how to make temp refer to a new object", then that is easy: temp = new Player(); or whatever constructor you wish to use. -- /-- Joona Palaste ([EMAIL PROTECTED]) ------------- Finland --------\ \-------------------------------------------------------- rules! --------/ "Make money fast! Don't feed it!" - Anon == 3 of 6 == Date: Sun, Nov 21 2004 6:43 am From: "KiLVaiDeN" <[EMAIL PROTECTED]> "Andrew Thompson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sun, 21 Nov 2004 14:00:29 +0100, KiLVaiDeN wrote: > > > "Andrew Thompson" <[EMAIL PROTECTED]> wrote in message > ... > >> I suggest you include, > >> - an SSCCE <http://www.physci.org/codes/sscce.jsp> > ... > >> -- > >> 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 > > [1] > > > Andrew : why do you always .. > > [2] > > > ..have to .. > > [3] > > > ..post links to your website ? > > > [2] I do not always post links. Only where I feel they are relevant. > When I post links, I post links to the best information available > irrespective of the source. > > It just happens that most of the best sources of information (on questions > I feel qualified to comment upon) are on my site. They are on my site > because I put them there, just to save typing the answers again (and > again and again..). > > [3] I do not have to, I do do it as a service to the Java > developer community in general, and these forums in particular. > > [1] Unless you are referring to my sig., which you failed to edit > from your reply, so maybe this is a good time to point out.. > <http://www.physci.org/codes/javafaq.jsp#netiquette>, > (note last two paragraphs) unless you were indeed making > reference to my sig., in which case.. > <http://www.physci.org/codes/javafaq.jsp#specific> > > >..is it only for the hits? > > ? (shrugs) What's that mean? I am the only one that knows how > many hits I have, and even then I am not entirely clear on how to > read the server stats. I also have Google and other advertising > on my sites. All the 'click-thru' ads for which I get paid end > up covering about one third of the cost of the server. I would > remove them and recalim my precious screen acreage except for > the fact that Google indexes my pages sooooo fast. [ ;-) ] > > > Was just wondering :) > > Am just answering. > > -- > 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 I didn't criticize your work, I really appreciate reading your answers most of the time, And I think your website is really well filled with usefull information. I didn't edit your sig as well, just did a reply to group from outlook express. You could try it yourself, to reproduce it. I wish that people like you who help the community, would at least have their website paid from advertising, so I wish you good luck with it ;) and don't take my first reply bad. K == 4 of 6 == Date: Sun, Nov 21 2004 6:59 am From: Andrew Thompson <[EMAIL PROTECTED]> On Sun, 21 Nov 2004 15:43:46 +0100, KiLVaiDeN wrote: > I didn't edit your sig as well, just did a reply to group from outlook > express. You could try it yourself, to reproduce it. (whispers) I actually meant you *should* have trimmed my sig. from your reply. Sigs. from earlier messages are not needed in a reply, they are just a waste of bandwidth. > I wish that people like you who help the community, would at least have > their website paid from advertising, so I wish you good luck with it ;) Thanks. :-) >..and don't take my first reply bad. LOL. Heck no! I enjoy any opportunity to discuss me and/or my site. ;-) -- 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 6 == Date: Sun, Nov 21 2004 7:26 am From: "KiLVaiDeN" <[EMAIL PROTECTED]> "Andrew Thompson" wrote : > (whispers) I actually meant you *should* have trimmed my sig. > from your reply. Sigs. from earlier messages are not needed > in a reply, they are just a waste of bandwidth. I never thought of that waste of bandwidth thing, but you are right, it's something to care about eventually ;) But why would we bother triming messages, using some of our time, while some people overuse bandwith with 100000x bigger downloads, and 100000x more useless things ? Well :) I won't complain ! K == 6 of 6 == Date: Sun, Nov 21 2004 7:49 am From: Andrew Thompson <[EMAIL PROTECTED]> On Sun, 21 Nov 2004 16:26:47 +0100, KiLVaiDeN wrote: > "Andrew Thompson" wrote : >> (whispers) I actually meant you *should* have trimmed my sig. >> from your reply. Sigs. from earlier messages are not needed >> in a reply, they are just a waste of bandwidth. > > I never thought of that waste of bandwidth thing, but you are right, it's > something to care about eventually ;) I'd prefer people think about it now [see 1), 2)] > But why would we bother triming messages, using some of our time, while some > people overuse bandwith with 100000x bigger downloads, and 100000x more > useless things ? What have those people got to do with this? If people with fat broadband wish to squander bandwidth downloading porn and ripped StarWars trailers, that's their business. I am thinking of two other things primarily. 1) People who wish to subscribe to, or read, the group, but are limited to dial-up. 2) Archives, such as Google, which might choose to drop* groups if the sheer weight of the posts became too much. * It may sound far-fetched, but for a brief time after the demise of Deja-News, the public archives of groups were effectively in limbo. I feel the interest of such archives in carrying groups depends on the Signal/Noise ratio of each group. Many contributors to these groups work to ensure the S/N ratio of the Java groups remains high enough to make it worth their effort. This way, we can all benefit from the ease of searching the earlier posts (and the knowledge base contain therein). -- 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: SOLD GOOG bought BE http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/662b70234da635f3 ========================================================================== == 1 of 1 == Date: Sun, Nov 21 2004 6:09 am From: [EMAIL PROTECTED] (Cindi Jenkins) They have secured several new government contracts which of course will run over budget and create additional revenue opportunities.... The Visitor <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Should I know why? > > Cindi Jenkins wrote: > Bearingpoint (BE) is a good stock play. > > Currently trading at $9 and should shoot to $12 by end of year. ========================================================================== TOPIC: Http server question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fe0bdc9ae6fb0c60 ========================================================================== == 1 of 1 == Date: Sun, Nov 21 2004 6:34 am From: [EMAIL PROTECTED] (Yakov) This may help: http://www.sys-con.com/story/?storyid=39248 Regards, Yakov ========================================================================== TOPIC: JSP/Servlets J2EE http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bb75a63dcb4eb0db ========================================================================== == 1 of 2 == Date: Sun, Nov 21 2004 6:37 am From: [EMAIL PROTECTED] (Yakov) Since JSP and servlets are J2EE components, it's J2EE application Regards, Yakov == 2 of 2 == Date: Sun, Nov 21 2004 7:13 am From: Sudsy <[EMAIL PROTECTED]> German Gonzalez wrote: > Hello, > > Still I'm not sure about JSP/Servlets and J2EE architecture. > I know those technologies are the "Web Tier" of J2EE and > EJB is the "Business tier". > http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Overview2.html#wp81104 > > but if I only use Tomcat as Application Server (to use only JSP/Servlets) > and copy the Servlet.jar to my j2se-jdk. I'm getting J2EE tech, then I'm > using J2EE!? > > I would like to know if I use only JSP/Servlet is still a J2EE application > or It needs to have EJB to became a J2EE app? Read up on the differences between the war and ear formats. You can run a war on either a servlet container like Tomcat or a J2EE server. You can only run an ear on a J2EE server. war <-> Web Application ear <-> Enterprise Application -- Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development. ========================================================================== TOPIC: Using <jsp:getProperty> within rtexprvalue Attributes http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/83818b0ae9771445 ========================================================================== == 1 of 2 == Date: Sun, Nov 21 2004 6:42 am From: [EMAIL PROTECTED] (Stephan Melchior) How can I use <jsp:getProperty> Tag as value of an attribute within a customTag. Example: <psws05:Currency cunit="dollar" value='<%=pizza.getPreis()%>'/> works fine, but <psws05:Currency cunit="dollar" value='<jsp:getProperty name="pizza" property="preis"/>'/> does not work 'cause the Setter of the preis Attibute is feed with the String <jsp:getProperty name="pizza" property="groesse"/> and not the value of the expression. Any ideas? Greetings Stephan == 2 of 2 == Date: Sun, Nov 21 2004 7:36 am From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> [EMAIL PROTECTED] (Stephan Melchior) writes: > <psws05:Currency cunit="dollar" value='<jsp:getProperty name="pizza" > property="preis"/>'/> does not work 'cause the Setter of the preis > Attibute is > feed with the String <jsp:getProperty name="pizza" > property="groesse"/> and not the value of the expression. Correct: Just as in XML in general, elements cannot be inside tags like that. Use the autogenerated variable like this: <psws05:Currency cunit="dollar" value='<%=pizza.getPreis()%>'/> ========================================================================== TOPIC: references and a binary tree http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d897505b2c28f461 ========================================================================== == 1 of 4 == Date: Sun, Nov 21 2004 6:48 am From: [EMAIL PROTECTED] (Milan Stezka) Hello, I am new to Java. I am filling a binary tree with values using a loop, so when I need to descend one node deeper at the end of the loop, I use node=node.right for example. Consider this pseudo code: //... while(1) { node=new Node(new Leaf(),null); node=node.right; } I thought that the node variable will contain reference after this operation. But it does not, because when I look at the root of the binary tree, it does not get filled any further after the node=node.right operation. So my question is, what actually happens in the node=node.right , I tought that it should be only copying the references, not the values. I coded the same in c++ and instead of references I used the pointers and it worked right as I expected. == 2 of 4 == Date: Sun, Nov 21 2004 7:04 am From: Neil Campbell <[EMAIL PROTECTED]> Milan Stezka wrote: > Hello, > > I am new to Java. I am filling a binary tree with values using a loop, > so when I need to descend one node deeper at the end of the loop, I > use node=node.right for example. Consider this pseudo code: > > //... > while(1) { > node=new Node(new Leaf(),null); > node=node.right; > } It looks as though you are creating a node (with new Node(...)), with a single child (the new Leaf). Then you assign a reference to this child to node. Next time around the loop, you create another new Node, and assign a reference to this to node, thus losing the reference you assigned with node=node.right. I'm not entirely certain what you're trying to do; but if you want to add a new child node on to the end of the tree, you have to assign it to node.right (or node.left): node.right = new Node(...); ...but I'm not sure I've really understood your question. Neil -- Neil Campbell batneil[AT]thebatcave[DOT]org[DOT]uk http://www.thebatcave.org.uk == 3 of 4 == Date: Sun, Nov 21 2004 7:18 am From: "Stefan Schulz" <[EMAIL PROTECTED]> On 21 Nov 2004 06:48:37 -0800, Milan Stezka <[EMAIL PROTECTED]> wrote: > Hello, > > I am new to Java. I am filling a binary tree with values using a loop, > so when I need to descend one node deeper at the end of the loop, I > use node=node.right for example. Consider this pseudo code: > > //... > while(1) { > node=new Node(new Leaf(),null); > node=node.right; > } > > I thought that the node variable will contain reference after this > operation. But it does not, because when I look at the root of the > binary tree, it does not get filled any further after the > node=node.right operation. What happens? NullPointerException? StackOverflowErrror? WannaGoForAWalkError? Endless loops terminating prematurely usually have some exceptional reason to do so. ;) > So my question is, what actually happens in the node=node.right , I > tought that it should be only copying the references, not the values. > I coded the same in c++ and instead of references I used the pointers > and it worked right as I expected. I have no idea. Post your code (at least the relevant portion). So far i can only guess what you mean... What does the node constructor do? If i guess that you mean to create a new Leaf as a left child, and null as the right child, the right way to do it would be Node node = new Node(new Leaf(), null); while (!exit) { node.right = new Node(new Leaf(), null); node = node.right; } node.right = new Leaf(); -- Whom the gods wish to destroy they first call promising. == 4 of 4 == Date: Sun, Nov 21 2004 7:35 am From: Andrew Thompson <[EMAIL PROTECTED]> On Sun, 21 Nov 2004 16:18:09 +0100, Stefan Schulz wrote: > On 21 Nov 2004 06:48:37 -0800, Milan Stezka <[EMAIL PROTECTED]> wrote: ... >> I thought that the node variable will contain reference after this >> operation. But it does not, because when I look at the root of the >> binary tree, it does not get filled any further after the >> node=node.right operation. > > What happens? NullPointerException? StackOverflowErrror? > WannaGoForAWalkError? .. My money is on WannaGoForAWalkError. To the OP, it would be helpful to be specific[1] and precise[2]. [1] <http://www.physci.org/codes/javafaq.jsp#specific> [2] <http://www.physci.org/codes/javafaq.jsp#exact> >> So my question is, what actually happens in the node=node.right , I >> tought that it should be only copying the references, not the values. >> I coded the same in c++ and instead of references I used the pointers >> and it worked right as I expected. > > I have no idea. Post your code (at least the relevant portion). The trouble is determining what is relevant*. I generally recommend a complete SHORT example from start to finish. <http://www.physci.org/codes/sscce.jsp> This has various advantages, including that - trimming code to the bare minimum often reveals the problem - complete code is much easier to assess, since we can see it run (or fail) for ourselves. * I have found that a person's ability to judge what is relevant is not very good when they do not fully understand what is happening, which is (almost without fail) the case when someone posts a question. -- 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: Microsoft to make Visual Studio Open Source http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/76bb971914b255fe ========================================================================== == 1 of 1 == Date: Sun, Nov 21 2004 7:00 am From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> [EMAIL PROTECTED] (Cindi Jenkins) writes: > Visual Studio news at http://blogs.ittoolbox.com/eai/leadership Spamming to draw traffic to someone's blog? For shame. ========================================================================== TOPIC: Environment variable http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e10a85f420f52962 ========================================================================== == 1 of 1 == Date: Sun, Nov 21 2004 6:58 am From: Michael Borgwardt <[EMAIL PROTECTED]> Glynne wrote: >>>or is it "forbidden" to use environment vars in java? >> >>It is stringly discouraged, since it's not portable. Some systems don't >>have environment variables at all (such as pre-X MacOS), and they don't >>behave the same on all systems that do. > > > > By the same logic, some systems don't have a GUI, so why don't we deprecate > Swing and the AWT? Because they cannot be emulated by something more portable. There's nothing you can do with environment variables that can't be done with system properties, with less potential for incompatibilities or other problems. > Considering that the behavior of the JVM itself can be altered by the > presence of the CLASSPATH environment variable, Which causes problems all the time and is deprecated. The very fact that every single Java introduction book needed to contain a chapter on "how to set up your CLASSPATH" (which is the reason why the damn thing isn't gone and forgotten) proves that it was a bad idea. ========================================================================== TOPIC: 2 interface with 2 same function prototype but different return type http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5277abed8de68298 ========================================================================== == 1 of 1 == Date: Sun, Nov 21 2004 7:47 am From: "xarax" <[EMAIL PROTECTED]> "Joona I Palaste" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > steve <[EMAIL PROTECTED]> scribbled the following: > > On Sun, 21 Nov 2004 01:16:09 +0800, xarax wrote > > (in article <[EMAIL PROTECTED]>): > >> "cai junfu" <[EMAIL PROTECTED]> wrote in message > >> news:[EMAIL PROTECTED] > >>> interface a{ > >>> int g(); > >>> } > >>> > >>> interface b{ > >>> double g(); > >>> } > >>> > >>> class c implements a, b{ > >>> } > >>> > >>> > >>> how should class c's implementation of the two interface be written? > >>> is it possible at all? > >> > >> Cannot happen in Java. The method return types > >> must be the same (ignoring the Generics thing). > >> > >> You can do an alternative using objects like this: > >> > >> public interface A > >> { > >> public abstract Number g(); > >> } > >> > >> public interface B > >> { > >> public abstract Number g(); > >> } > >> > >> public class C > >> implements A,B > >> { > >> public Number g() > >> { > >> Integer a; > >> Double b; > >> Number result; > >> > >> if(/* some condition */) > >> { > >> a = new Integer(12); > >> result = a; > >> } > >> else > >> { > >> b = new Double(20.5); > >> result = b; > >> } > >> return result; > >> } > >> > >> The caller of C.g() must then decide how to > >> extract the value of the Number result. > > > you can return a different "type", just cast the type to an object, return > > an object, > > then in your main calling code do a test for "instance of" XX or instance of > > YY. > > Isn't that exactly what xarax did in the above code? > However, I'd write it the following way: > > public interface A { > public Number g(); > } > > public interface B { > public Number g(); > } > > public class C implements A, B { > public Number g() { > if (/* some condition */) { > return new Integer(12); > } > else { > return new Double(20.5); > } > } > } > > Note that explicitly casting the returned object reference to a > superclass type is usually not needed. In fact I have written code > similar to the above and only had to use upcasting in a ?: expression > where neither of the returned references was a supertype of the other. I was writing extremely verbose example so that the casual/newbie reader could see what was happening. Also, I come from a Structured Programming background (from the days before Object Oriented Programming), so I always insist that my code have only one "return" statement. Your mileage may vary. btw: One of the nice things about Number is that the caller doesn't really need to use "instanceof", because it has the various methods for extracting the value as various primitives. So, just use the Number instance without caring about the actual subtype. (Polymorphism is fabulous.) ========================================================================== TOPIC: limitations of Java VM under Windows/Linux? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc3538556e5ad6cd ========================================================================== == 1 of 1 == Date: Sun, Nov 21 2004 7:48 am From: Angus Parvis <[EMAIL PROTECTED]> hiwa wrote: > I like to read paper written based on writer's own real experience and > state-of-mind. I agree, but as a university student I don't have experience enough .. > Limitation I feel for Java is lack of true reference-passing in method > call. Thx, but I guess this is a limitation of Java in general and does not behave different under Linux/Windows. ========================================================================== TOPIC: Using com.sun.tools.javac.Main() for compiling http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/894f2738d346f374 ========================================================================== == 1 of 1 == Date: Sun, Nov 21 2004 8:02 am From: [EMAIL PROTECTED] (Jesper Sahner) ExGuardianReader <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > hiwa wrote: > > "Fahd Shariff" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL > > PROTECTED]>... > > > >>You could create a Temporary file which you can delete later on. > >> > >>Or you can look at javac's source code and see if there is any other > >>method that might do what you are looking for... > > > > > > Using temporary file is good because no hack is needed. We can't > > access javac's input stream by a standard way. > > I've looked at the source code, and there seems to be no other access to > the compiler other than through a file. > > This seems very poor design with InputStreams available. We should to be > able to provide an InputStream of Java source code to a compiler method > to generate new bytecode. Agreed! There are some byte-code generators around, e.g. BCEL, ASM, Soot etc., but for this it is "overkill". > Generating skeleton server classes would be much neater if you could do > this. Could you explain this in more details or add some keywords? Regards, Jesper ========================================================================== TOPIC: How 'java' (command) handles the classname passed http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/908d4e10411ee318 ========================================================================== == 1 of 1 == Date: Sun, Nov 21 2004 8:06 am From: [EMAIL PROTECTED] (kris) Hi, After compiling the .java file, the .class is passed to 'java' and that runs the program. Does the 'java' work this way: when we give "java classname", 'java' strictly would search for classname.class and proceeds thereafter, The reason i got this doubt is when i gave a command "java classname.class" an error was raised pointing no class definition. Thanks for your time. Krishna. ======================================================================= 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
