Within void constructor...how can return an object?

i got the following
public void Player (String name,String key,Server server)
     gui = new PlayerGUI();
server.addServer(this);
return(Player)PlayerSet.getPlayers; // obviously this line is incorrect....but I need to return a valid object....within this void method?!?
this is the default constructor...it can be void only....
how can i do it?!

i got the following
public void Player (String name,String key,Server
server)
     gui = new PlayerGUI();
server.addServer(this);
return(Player)PlayerSet.getPlayers; //
yers; // obviously this line is incorrect....but I
need to return a valid object....within this void
method?!?
this is the default constructor...it can be void
only....
how can i do it?!constructor ? no, this is a method...
constructor cannot have the return type
example :
public Player(String name, String key, Server server) {
}if it's a method and you want to return something then it should look something like
public Player getPlayer(String name, String key, Server server) {
}

Similar Messages

  • How to return java objects on the button click

    hello all,
    i wonder if any body let me know ,how to return java objects on button click,
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    class base
         base()
              JFrame frame = new JFrame("Base class Message Dialog Box");
              JPanel panel = new JPanel();
              JButton buttonchildone = new JButton("Child class one");
              buttonchildone.addActionListener(new ActionListener(){
                   public actionPerformed(ActionEvent e)
                        childone ch1=new childone();
                   return ch1;
              JButton buttonchildtwo = new JButton("Child class two");
              buttonchildtwo.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e)
                        childtwo ch2=new childtwo();
                        return ch2;
              panel.add(buttonchildone);
              panel.add(buttonchildtwo);
              frame.add(panel);
              frame.setSize(300, 300);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         void show()
              System.out.println("Base class show() method");
    public class mainmethod
         public static void main(String[] args)
              base baseobj=new base();
    here my aim is to achieve dynamic polymorphism by button click's ,where based on the button click i can send back an object of childone or childtwo classes
    thanks and regard
    Mac
    Message was edited by:
    LoveOpensource

    You probably need to rethink your design. Where are these child classes going? What is using or consuming them? I agree with the message above about a button instantiating a parent field variable to one child or the other depending on which button is pressed.
    Message was edited by:
    petes1234

  • Hi,how can i transport objects from one server to other like (Dev To Qty)

    Hi Sir/madam,
       Can u explain how can i transport objects from one server to other like (Development To Quality To Production).
    Regards,
    Vishali.

    Hi Vishali,
    Step 1: Collect all Transports(with Packages) in Transports Tab(RSA1)- CTO
    Step 2: Release the subrequests first and then the main request by pressing Truck button
    Step 3: STMS or Customized transactions
    Object Collection In Transports:
    The respective Transports should have the following objects:
    1. Base Objects -
    a. Info Area
    b. Info object catalogs
    c. Info Objects
    2. Info Providers u2013
    a. Info Cubes
    b. Multi Providers
    c. Info Sets
    d. Data Store Objects
    e. Info Cube Aggregates
    3. Transfer Rules u2013
    a. Application Components
    b. Communication Structure
    c. Data Source replica
    d. Info Packages
    e. Transfer Rules
    f. Transformations
    g. Info Source Transaction data
    h. Transfer Structure
    i. Data sources (Active version)
    j. Routines & BW Formulas used in the Transfer routines
    k. Extract Structures
    l. (Note) If the transfer structures and related objects are being transferred without preceding
    Base Objects transport (e.g. while fixing an error) it is safer to transport the related Info
    Objects as well.
    4. Update Rules u2013
    a. Update rules
    b. Routines and formulas used in Update rules
    c. DTPs
    5. Process Chains u2013
    a. Process Chains
    b. Process Chain Starter
    c. Process Variants
    d. Event u2013 Administration Chains
    6. Report Objects u2013
    a. Reports
    b. Report Objects
    c. Web Templates
    Regards,
    Suman

  • How can I pass objects across neywork?

    How can I pass a ObjectOutputStream to a ObjectInputStream, across a socket?
    Thanks in advance for your posts!

    Or maybe I am misunderstanding your question?-Probably
    Lets see: ObjectOutputStream passes data trought aout
    Stream; ObjectInputStream receives data trought a in
    Stream: so, I suppose that they can use as streamsthe
    connections betwen two sockets, in one point the
    ObjectOutputStream sending, an in another the
    ObjectInputStream receiving.Yes. The sockets provide the connections, and you can
    call getInputStream or getOutputStream on the sockets
    to read what the other guy is sending, or to write to
    the other guy. You don't actually pass the sockets or
    streams back and forth--they're just the channels by
    which you pass your data.I knew that, thanks anyway. But my question is how can I pass objects throught that streams.
    Anyone knows?
    Thanks

  • How can I delete objects in my list of purchased objects?

    How can I delete objects like books or music from my list of bought items?

    You can't.
    Being able to do so would NEGATIVELY affect Apples iCloud system of memorizing all consumer purchases as a means of storing such info in the Cloud.

  • How can i convert object to byte array very*100 fast?

    i need to transfer a object by datagram packet in embeded system.
    i make a code fallowing sequence.
    1) convert object to byte array ( i append object attribute to byte[] sequencailly )
    2) send the byte array by datagram packet ( by JNI )
    but, it's not satisfied my requirement.
    it must be finished in 1ms.
    but, converting is spending 2ms.
    network speed is not bottleneck. ( transfer time is 0.3ms and packet size is 4096 bytes )
    Using ObjectOutputStream is very slow, so i'm using this way.
    is there antoher way? or how can i improve?
    Edited by: JongpilKim on May 17, 2009 10:48 PM
    Edited by: JongpilKim on May 17, 2009 10:51 PM
    Edited by: JongpilKim on May 17, 2009 10:53 PM

    thanks a lot for your reply.
    now, i use udp socket for communication, but, i must use hardware pci communication later.
    so, i wrap the communication logic to use jni.
    for convert a object to byte array,
    i used ObjectInputStream before, but it was so slow.
    so, i change the implementation to use byte array directly, like ByteBuffer.
    ex)
    public class ByteArrayHelper {
    private byte[] buf = new byte[1024];
    int idx = 0;
    public void putInt(int val){
    buf[idx++] = (byte)(val & 0xff);
    buf[idx++] = (byte)((val>>8) & 0xff);
    buf[idx++] = (byte)((val>>16) & 0xff);
    buf[idx++] = (byte)((val>>24) & 0xff);
    public void putDouble(double val){ .... }
    public void putFloat(float val){ ... }
    public byte[] toByteArray(){ return this.buf; }
    public class PacketData {
    priavte int a;
    private int b;
    public byte[] getByteArray(){
    ByteArrayHelper helper = new ByteArrayHelper();
    helper.putInt(a);
    helper.putInt(b);
    return helper.toByteArray();
    but, it's not enough.
    is there another way to send a object data?
    in java language, i can't access memory directly.
    in c language, if i use struct, i can send struct data to copy memory by socket and it's very fast.
    Edited by: JongpilKim on May 18, 2009 5:26 PM

  • How to return a object from a method in a java program to a C++ call (JNI )

    Sir,
    I am new to java and i have been assigned a task to be done using JNI.
    My question is,
    How can i return an object from a method in a java program to a call for the same method in a C++program using JNI.
    Any help or suggesstions in this regard would be very useful.
    Thanking you,
    Anjan Kumar

    Hello
    I would like to suggest that JNI should be your last choice and not your first choice. JNI is hard to get right. Since the JNI code is executing in the same address space as the JVM, any problems (on either side) will take down the entire process. It dilutes the Write Once Run Anywhere (WORA) value proposition because you need to provide the JNI component for all hardware/OS platforms. If you can keep your legacy code(or whatever you feel you need to do in JNI) in a separate address space and communicate via some inter-process channel, you end up with a system that is more flexible, portable, and scalable.
    Having said all that, head over to the Java Native Interface: Programmer's Guide and Specification web page:
    http://java.sun.com/docs/books/jni/
    Scroll down to the Download the example code in this book in ZIP or tar.gz formats. links and download the example source. Study and run the example sources. The jniexamples/chap5/MyNewString demo creates a java.lang.String object in native code and returns it to the Java Language program.

  • How can i hide object in line chart?

    In Webi XI R2, i am preparing a line chart for which on x-axis i have two objects like "month name" and "month ID". The purpose of "month ID" is to sort the month name. So sorting is applied on "month ID" column. Now how can i hide this "month ID" column, but still sorting is applied so that month name is displayed in correct order.
    secondly, on the x-axis values are displaying like "AUG/00987","SEP/00988". i.e Month name/month ID. How can i make the line chart to display only month name but still sorting needs to be applied.
    Please advise.

    Hi Raveendra,
    You can try to hide the column from the webi report in a TABLE, and might just work with the table, and make them charts.
    regards,
    Shreyash.

  • How can I Create object dybatically

    hi all , I am a new user of develope 6.0 ,now i have a problem
    Can I create a object such as block,item dymatically , How can i
    do for this job ?
    null

    six Lu (guest) wrote:
    : hi all , I am a new user of develope 6.0 ,now i have a problem
    : Can I create a object such as block,item dymatically , How can
    i
    : do for this job ?
    you can create blocks and items only at design time, not at
    runtime. The only objects you can dynamicaly are timers and
    navigator trees.
    peter
    null

  • Animation: how can I move objects (and their transform keyframes)?

    Hi,
    I have created a project with a group of layers which all move (have transform keyframes set up).
    Now I want to move the group, but when I do this and then run the animation, the position of all the transform keyframes I have set up remain in the same place.
    Is there some way to move a group of objects and the location of their transform keyframes at the same time, or will I have to go through each keyframe and move them individually?
    Thanks!
    Jack

    > PLEASEEE HELPP
    You need to get some understanding of HTML and CSS to know
    why building a
    web page is not like using a page layout program or even a
    word processor.
    Unfortunately that will require some effort on your part.
    You cannot just place things on the page in HTML - you need
    to build an HTML
    infrastructure to hold the elements you want to appear on the
    page, and to
    hold them in the location where you want them to appear. As a
    simple
    example, consider a 1 row by 2 column table, where each
    column is set to 50%
    width, and the table itself is 800px wide. An image placed
    into the second
    column will be located exactly 400px from the left margin of
    the page
    (assuming a) the image is less than 400px wide, b) the table
    has zero
    borders, cellspacing and cellpadding, and c) there is nothing
    wider than
    400px in the first column.
    Make sense?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "afsheenm" <[email protected]> wrote in
    message
    news:fftbo8$cok$[email protected]..
    > hi, its my first time making the website so i have no
    clue about anything.
    > how
    > can i move text box? i mean i wrote something and want
    to move its
    > position
    > like up or down, how can i move it? also tables??????
    sometimes i can move
    > them
    > , by chance but i have no clue how i did it? PLEASEEE
    HELPP.
    >

  • How can I use Object's methed by OO4O

    I have done a type as following
    create or replace type classteacher as object
    tchid number,
    tchname varchar2(30),
    tchhomepage varchar2(100),
    tchsex varchar2(4),
    member procedure getCourseList(crslist out sys_refcursor)
    and the method is define as following
    create or replace type body CLASSTEACHER is
    member procedure getCourseList(crslist out sys_refcursor)
    is
    begin
    open crslist for
    select a.crs_id,a.crs_name,a.crs_notice
    from tb_courselist a,tb_teacher b
    where trim(a.tech_name) = trim(b.name)
    and b.teacher_id = tchid;
    end;
    how can I use the method by OO40 in vb.net.

    What is that post supposed to be?

  • How can i read Object serialized in delphi ?

    anyone has got any ideas how can i read serialized object created by delphi and was serialized in a file

    zeda wrote:
    Peter__Lawrey wrote:
    To my knowledge you need a Delphi program to read it.so there is no 3rd party plugin or so?Not that I know of. You could learn more about how Delphi serializes objects, and work back from there. But you're probably much better off taking a hint from Peter and serializing to XML in the first place. This sort of problem is the exact kind of thing XML is good at solving

  • How to return custJava Object from Java Stored Function/Procedure to Java Application

    I WILL PAY $100 FOR SOLUTION.
    Oracle JDBC documentation gives step by step on how to return Oracle Type Object to Java Application. No question here.
    But is it possible to create Java Stored Function [getMyClass() ] which returns CUSTOM Java based object [MyClass] to Java application like:
    //java stored function
    class Foo
    public static MyClass getMyClass()
    return new MyClass();
    //java class I want to return to Java
    class MyClass
    public String getGreetings(String name)
    return "Hello " + name;
    I tried to do it using intermittent Oracle
    Type Object and OracleConnection map to make binding between Java->Oracle->Java. I could
    not get throgh meaningless run time ORA Errors. Any kind of help would be greatly
    appreciated. If you know the answer please
    post it or e-mail [email protected]
    null

    You don't say which version of the database you are on. There's an interesting looking article on OTN on handling CLOBs in JDBC in 10g. It may well be useful for earlier versions too (but no guarantees).
    Cheers, APC

  • How can i save object in file ?

    For example I have some object in the memory, and i want to save it on the disk, and after i'm going load this object in memory and work with him...How can i do it ?
    May be I must use JavaSpaces technology (but i don't enought knows this) ?
    Please help me.
    [email protected]

    Serializing an Object:
    try
    ObjectOutputStream myOutput ObjectOutputStream(new FileOutputStream("objects.out"));
    myOutput.writeObject("Hello! How are you on this very fine day?");
    out.close()
    catch(IOException e)
    System.err.println("Doh! You're probably writing to a file that you don't have permissions to access!");
    catch(ClassNotFoundException e)
    System.err.println("You should only get this if you're using some strange reflection stuff, or just try to output something that doesn't exist.. I don't really know why the compiler wouldn't catch this error instead otherwise");
    Getting that object back:
    try
    ObjectInputStream inObjects = new ObjectInputStream(new FileInputStream("objects.out"));
    String myObj = (String)in.readObject();
    System.out.println(myObj);
    Pretty simple. If you want to be more practical, and store more than one type of object in that file, you can use relfection:
    -Jason Thomas.

  • How can I get objects of multiple instances of InDesignServer

    Hello,
    We need to have InDesignServer running in more than one configuration. And we need to script them. So to keep easy let's pretend there are 2 instances of InDesignServer running. One startet with 'indesignserver -configuration conf0' and the other started with 'indesignserver -configuration conf1'.
    So we try (Visual Basic):
    dim myIndApp0 as InDesign.Application
    dim myIndApp1 as InDesign.Application
    myIndApps0 = CreateObject("InDesignServer.Application.CS2")
    myIndApps1 = CreateObject("InDesignServer.Application.CS2")
    But both objects referring to the instance with conf0. How can we get an object of the second instance?
    We tried to solve this using System.Diagnostics.Process.GetProcesses(). So we got both processes. But did not find a way to get an object of class InDesignServer.Application by using an object of System.Diagnostics.Process. Any ideas about that way?

    Hi Ian,
    The problem is not to start different instances. In the Windows Task Manager and the console output of InDesign Server I can see, that both instances are running with different configurations. When I use Systems.Diagnostics.Processes.GetProcess() I get both processes too.
    But I don't know how to get objects of both instances using the Interop Assembly or (as a runaround) how to cast an object of System.Diagnostics.Process into an object of InDesignServer.Application.
    When you talking about SOAP, do you know how to start InDesignServer twice with diffrent ports from inside VB and getting the InDesignServer.Application objects of it?
    This should be solve our problem too.

Maybe you are looking for