@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3



Comments:

<0> is it possible or not to use INPUT parameters and OUTPUT parameters in java methods ? (and make the difference explicit, as it is in C++ with "const" keyword).
<1> your question
<0> (sorry, I was waiting for someone who says "hey ! me ! i listen to you" ;)
<1> i dunno c++, but are you asking about p***ing by reference and by value?
<1> ahh :-)
<0> yeah, it seems that everythjing is "references" p***ed by value, so if the object has no "affectation" method, it can't be an output.
<0> (like String)
<0> and if object has affectation method, it can't be restrected to be an input (we can't forbid the use setXX() methods)
<0> (am i clear ?)
<1> hmm
<1> what might help you to remember is that all objects in java are p***ed by reference
<1> and all primitives are p***ed by value
<0> object are p***ed by reference, referenced are p***ed by value (it is important to remember that to be conscient that references are NOT like C++ pointeurs)
<0> do you understand the problem i said for String cl*** (for exemple) ?
<0> String object can't be p***ed as an output parameter
<0> because the only thing you can do is create a new object and link it to the "temporary" reference, but you can't modify the object p***ed by reference (because String has no setters method)



<0> ok ?
<1> you can modify the p***ed string as only a reference is p***ed
<1> String s = "blah"; String t = s; t = "boo"; System.out.println(s);
<0> it print "blah".
<1> is that your question?
<0> it prints "blah", agree ?
<1> yes
<0> ok, that's the problem, imagine s is the parameter p***ed to a method wich do parameter_s = "boo"; then it is impossible to modify s as an output of the method, agree ?
<1> correct
<0> MyMethod(String s) {s = "Boo";} String z="Zed"; MyMethod(z); z will always stay "Zed" :'(
<1> they're essentially constants
<0> ok, is there a solution for z to be affected to "Boo" within the method ?
<1> you need a StringBuffer
<0> the only way i know is to use cl*** wich has z as attribute.
<0> ok.
<1> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/StringBuffer.html
<0> more generaly, the only way to use "output parameters" is to put them into another object, agree ?
<1> strings are special objects in this way
<0> what you mean?
<0> is it a normal way to think in java that: if my parameter is an input, i use String, if it is an ouput (or i/o) i use StringBuffer.
<0> I use different types to specify if parameter is Input or Output ?
<1> public cl*** MyInteger { public Integer myInt; public MyInteger(Integer myInt) {this.myInt = myInt;}} .... MyInteger a; MyInteger b; a = new MyInteger(1); b = a; b.myInt = 3;
<1> yeah if you want to change the value of your "string" you must p*** a StringBuffer
<1> when you p*** a string you're essentially p***ing a constant (this is what I mean by special)
<0> ok for strings, but it is the "general" way for other types, i mean, is it the general method to make the difference between Input and Outputs parameters in JAVA ?
<1> no it's not
<0> ok, so, what's the correct Java thinking to make difference between Input and Output parameters ?
<0> (that's my main question ;)
<0> (output are only p***ed by return value ? hope not.. ;)
<1> did you try my example and do System.out.println(a.myInt); at the end?
<0> it should print 3, correct ?
<1> if you want to return a primative, ie char, int, double, float... you must use "return variable" at the end of the method
<0> and for an object i must use it as an attribute of another cl*** (like do StringBuffer) ?
<1> you can change objects by p***ing in references to them in the formal parameter list and then using the mutator (eg. setX()) methods
<1> or by directly accessing their variables (as in my example)
<0> ok
<0> that's the good Java ways to do for output parameters ?
<1> it's generally good practice to make object variables (instance variables) private and use accessor and mutator methods to get and set their values (as i'm sure u know from c++)
<0> (i got another hot question ;)
<1> only if it's quick
<0> so, for Input parameters now, if my object is a nice object witch use only getters and setters, no public attribute
<0> how to ensure if i want to p*** it as an Input parameter that the method won't modify it (using setters) ?
<0> in C++ we simply add "const" keyword.
<0> in Java i must create another Cl*** to protect my object ? (like the couple of cl*** String (inputs) StringBuffer (outputs) ) ?
<1> you mean if it has setters but you don't want a specific method to use these to modify it?
<0> i want the method for witch my object is an INPUT to be unable to modify my object (unable to use setters)
<0> (in C++, if we try to modify a const parameters, even thru setters, it make compilation error ;)
<1> i guess you could wrap it in a method that overrides the set methods with empty ones?
<1> i see. well i don't think you can do that in java
<0> now i'm shocked.. we can't do that and we live without !?
<0> (like in C++ we live without exceptions verified by compilators)
<1> http://www.javacoffeebreak.com/articles/thinkinginjava/comparingc++andjava.html
<1> interesting qustion, i don't know C++ so I dind't know you could do that
<1> Regarding workarounds, you could do what I suggested but perhaps it's not the best solution and you'd be best to ask someone with java and c++ experience (with consts!)
<0> ok, thanks
<2> hm, new hibernate RC
<1> not a bit
<0> is there a sense to make a method parameter not "final" ?
<0> (i mean, there is no sense to modify the "local" reference loosing the reference to the p***ed object..)
<3> Axan: why not? depends on the situation.
<3> i tgry to avoid it, but sometimes, esp. when maintenance sets in, it is easiest to just modify the parameter(s) at a central location before going about them as usual.



<4> I tend to avoid it unless the param is used in an anonymous inner cl*** inside the method
<4> hey Clackwell
<3> moin talios
<0> i don't understand
<3> Axan: there are reasons where modifying the p***ed in values can make sense.
<0> make a parameter final let you modify it, but just protect you from changing the reference bind. agree ?
<3> there is nothing to agree. test it. the behavior that your test reveals is how it is supposed to work.
<3> (unless your test is broken, the jvm is broken or the java compiler is broken.)
<3> we don't need to discuss technical facts. :)
<3> (as they are given.)
<0> er.. i have nothing to test, what i said is right, isn't it ?
<3> Axan: i don't know. try it?
<0> objects are p***ed with reference, and references are p***ed by value, ok?
<3> Axan: perhaps so, perhaps not. test it?
<0> no, i'm sure with this.
<3> excellent. :)
<0> objects are p***ed by references, and references are p***ed by value.
<3> that sounds familiar.
<0> that's sure. but, now the problem i point is: does p***ing not final reference make sense ? (in C++ ie references are linked to the first object they point to)
<3> yes, so that you can change it and point elsewhere.
<3> setName(String name) { if (name.equals("****er") name = "Inappropriate"; doSomethingWith(name); }
<3> Axan, see?
<0> still here ?
<0> you method setName won't change the name even if it equals to "****er", it will stay "****er" after the method.
<0> because when you do: name = "Inappropriate", you just CREATE a new String("Inappropriate") and change the temporary local reference 'name' link to it.
<0> mystring = "****er"; setName(mystring); mystring still equals "****er". but name equals "Inappropriate", but is local to the function.
<5> hello
<6> kia ora aliveuser
<7> ??
<8> hello
<8> anyone can help with bufferstring, bytes and multi-thread server ?
<8> Clackwell: are you around my friend ?
<8> hi znabela
<8> can you help with bufferstring, bytes and multi-thread server ?
<9> can interfaces implement other interfaces?
<10> Morning.
<2> morning
<2> meh.. I hate it when IDEA tries to merge changes in my project files
<10> I hate that too, or I would if I understood it.
<11> I prefer doing it manually
<11> I never get on with auto-merging
<12> i heard you prefer doing it manually too deano
<2> Deano: I marked my project files as binary now, hopefully that will make subversion stop trying ot merge them
<10> I don't commit the IDE-generated stuff.
<2> I work on the same project from several diffrent computers, so having the prject files under revision controll helps
<10> Some people use two revision control mechanisms.
<10> E.g., subversion for the whole team and darcs just for themselves for hotdesking.
<2> just me on this project though
<10> Just me on mine.
<10> What's the project, out of random curiosity?
<2> this one is a personal project, just a little webapp I'm doing to get to know the tech
<11> well intellij has local history, which is good enough for individual control
<11> don't see the need for two revision control mechanisms though
<2> crookery: normally I work on CRM Software though, mainly groupware-CRM integration
<10> Deano: I think I just explained that need, or at least that use case.
<11> for hotdesking, fair enough if need be
<10> rsync would work too.
<11> beyond compare is v. useful too
<11> albeit not as automated as rysnc or fully fledged as your own cvs-esque repositary
<10> Eclipse is/was broken wrt the local history - I think they fixed it.
<10> Sometimes exiting the IDE would get rid of the history.
<2> anyway, I should get some lunch I suppose
<13> Hey guys, running into a brick wall with NIO with UDP. I've got a Selector that I register my DatagramChannel with, and when I receive a isReadable() event I spawn off to read the incoming data. Is there any way to determine the remote address for the incoming data BEFORE I read the contents of the message?
<14> hey. I have a Cl*** that extends JPanel, i have a component that extends Component. When i do add() to JPanel, the component doesnt appear
<14> if i put ....add(new JButton("qwerty")); then it appears
<14> i have override paint()
<14> to paint a custom component
<14> g.drawOval(50,50,50,50)
<10> anotherone: The JPanel is zero width and zero height.
<14> ah wait
<14> no that's not it
<14> i set ..setSize(400,400); on the JPanel


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #java
or
Go to some related logs:

#linux
#java
What room did W C Fields keep his library in
#linuxhelp
kabul etsene
gay faching pic
L-SPJUN
cangorous in Australia
c4244 abs c++
jeebos



Home  |  disclaimer  |  contact  |  submit quotes