Passing Information to a Method or a constructor

Hi henry, yawmark, Darry Buke, all
My last posting was a question. This i forgot to put question mark. Please look into it. I am ready to repeat it if you have any confusion.
Hi henry
I am satisfied with your answer which has been illustrated in your last posting.
damp

do you understand how forums work? why do you keep creating random threads?

Similar Messages

  • Passing information to a method

    Im going through the java tutorial about passing information to a method
    and i am presented with this code.
    class RGBColor {
        public int red, green, blue;
    class Pen {
        int redValue, greenValue, blueValue;
        void getRGBColor(RGBColor aColor) {// is aColor a reference for RGBColor ?
            aColor.red = redValue; //is aColor then used to access the variables of RGBColor ?
            aColor.green = greenValue;// Are these values being initialised here
            aColor.blue = blueValue;
    RGBColor penColor = new RGBColor();// we are creating an instance of RGBColor called penColor
    pen.getRGBColor(penColor);// this is the bit i dont understand where the heck did pen.getRGBColor come from, i cant see anywhere where pen has been declared ..... or instantiated
    System.out.println("red = " + penColor.red +
                       ", green = " + penColor.green +
                       ", blue = " + penColor.blue);The follwoing is what it says in the java tutorial about the code
    The modifications made to the RGBColor object within the getRGBColor method affect the object created in the calling sequence because the names penColor (in the calling sequence) and aColor (in the getRGBColor method) refer to the same object.
    any guidance would be great

    Directly above the code that you don't understand is
    o A definition for a class Pen.
    o something called "pen" is probably declared somewhere like this:
    Pen pen;
    or
    Pen pen = new Pen(....);
    or
    Pen pen = something.getPen();
    So pen is an instance of Pen, and you can invoke the methods defined in class Pen, thus
    pen.getRGBColor(....);

  • Member variable verses method parameter to pass information

    Hi all,
    Is the a performance penalty in using method parameter, such as a String, to pass information into multiple methods( method1(String X), method2(String X), etc ) in a class verses using a class member variable to pass the information to the methods?
    Thanks.

    Never, ever, ever make a decision as to what should be parameter and what should be field based on this kind issue. If the value is reasoably part of the state of the object it should stored (or referenced by) a field. Otherwise it should not and so your left with it being a parameter or an atribute of some other object.
    There is little if any performance cost in passing a parameter (on the order of 10's to 100's of nanoseconds on modern computers and JVM's. Optimizing in this area will only noticeably impact performance of such calls if it needs to get performed 100's of thousands or millions of times per second. That generally excludes everything any of us is likely to write.
    Chuck

  • Passing a Method into a Constructor!!!

    Hi:
    I am new to Java Programming. Can some one explain me how to pass a Method into a Constructor? Any help is appreciated.
    Thank you in advance.

    If you are new to Java I suggest you learn more about Java before asking questions like that. It is possible to do that, but you probably didn't mean what you said.

  • How can I pass information from one portlet to another?

    First, some background...
    I am using Portal 5.0.2 and developing portlets using JSP/Java on a remote server.
    I need to pass information from a portlet on pageA to another portlet on pageB, but I can't do it using the traditional methods, such as query string, session, cookies, etc. due to either portal framework limitations or because of functional constraints (basically, a user will not necessarily be logged in to the portal, but he can view anything available to the GUEST user). Here are the different ways I've considered using to save state and their limitations:
    Query string: can't use this because portlets on remote servers don't have access to it
    Cookies: if user disables cookies, code will not function properly
    Session variables: limited to one user's connection with one portlet (i.e., can't access a session variable set in portletA from portletB)
    Application variables: because the user may not be logged in, I have no way of uniquely naming variables, which is a necessity in order to maintain state for EACH user
    User Settings: again, the user may not be logged in, so I can't use these
    PCC: can't access client-side variables because server-side JSP executes first
    Are my assumptions above correct? Has anyone had any success using one of these methods given the same constraints, or does anyone have an alternative solution? I'd certainly appreciate any help anyone could provide.
    Thanks,
    Jose

    One possibility would be to use a Login PEI to set a unique UserInfo Name/Value for the user. I think in 5.0 each guest session is unique, so would have unique UserInfo. Then you could pass this value to your portlet (by specifying it in the web service) and use it as a key into a Application-scoped hashmap where you store your info. In other words, your Application variables option, but you have a way of uniquely naming your variables via PEI-set UserInfo.

  • Passing information between class

    Greetings Fellow Developers,
    I have what I believe to be a simple question but my brain is only thinking in procedural at the moment so I'm in a bit of a fix.
    I'm working on a midlet and creating an message book application
    I must pass informatin class mesaj to JSMS
    public class mesaj extends DisplayTextBox{
          private static String mes="";   
        public mesaj() {
            super("mesajınız",TextField.ANY);
       public  void setMesaj(){
            mes=getString();
        public static String getMesaj(){
            setMesaj();//there is problem with use static method
            return mes;
    public class JSMS extends MIDlet implements CommandListener{
       public void commandAction(Command c, Displayable d) {
             if(c==add){
                AddRecord(mesaj.getMesaj);
    }I have a problem using getMesaj method...
    can I passed information without non-static method
    thanx
    muratti32

    Hi,
    I think that your set and get methods are a bit wrong. Maybe they should be like this
    public void setMesaj(String m)
      mes = m;
    public static String getMesaj()
      return mes;
    }if you don't want to make static methods, you'll have to make an instance of the class, which methods you want to call.
    public class JSMS extends MIDlet implements CommandListener{
    private mesaj m = new mesaj();
       public void commandAction(Command c, Displayable d) {
             if(c==add){
                AddRecord(m.getMesaj);
    }kari-matti

  • How can pass information between 2 par file in iView???

    Hello,using PDK i've have created an iview calling 2 .par file, the first par file contains a menu that the user selects a products and then when press load button generates a table with information. The table with information is generated in second .par file, that collects the information passed by the menu (through beans) and with a BAPI generates the table. I made it because the menu must be separated in one frame, and the table in other...(and the first frame must displace, how a html frame)
    The question, how can pass information between two par files or if are another method to made 2 frames????
    I'm using jsp,HTMLB .
    Thanks.

    Hi,
    try to have a look to the docs contained in this zip file.
    They explain how to implement a portal component, a portal service and how to implement comunication between portal components, using POM and other features.
    Maybe could be a good starting point for you
    the file is
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/component and service creation tutorial.zip
    Ciao
    Roberto

  • Pass information between dom0 & domU thanks to web service API

    I have to build automation API in Java programming language for application deployment on virtualized infrastructures. Is there any way to pass information to application running inside the deployed virtual machine and to notify the host about some application's states? Everything using only the Webservice API...
    The principal examples I can give:
    For VMware (Virtual Infrastructure compliant products) & Virtualbox infrastructures, WS API give use the capability to set variables to retrieve them thanks to the guest tools ( vmware-guestd & VBoxControl )...
    For XenServer and Hyper-V, the only way we found to get that done is to directly write the variables in a part of the virtual machine configuration. Then, from the virtual machine, we need to connect to the XenServer/Hyper-V, identify the virtual machine which is currently running our application, and use it to retrieve the application configuration... The problem with the later is that we have to "hard write" the authentication information in the virtual machine, and to find a way to determine in which virtual machine the application is running ( this is done so far using NIC Mac address ).
    Because of the "light" documentation, i don't know if such a thing is possible for OVM manager...

    My mistake...
    on [http://download.oracle.com/docs/cd/E11081_01/doc/web.21/e14979/toc.htm|http://download.oracle.com/docs/cd/E11081_01/doc/web.21/e14979/toc.htm] , the method
    void      createPropertiesFileOnVirtualMachine(java.util.Properties props, VirtualMachine vm, java.lang.String propFileName)seems to do what I need...
    Now, because my test environment only allow PV Guests, I'd like to know if that also work for HW Guests?

  • Passing information from external asp file and getting it in the portal

    Hi,
    I think that the answer for my question is simple but I'm not sure how it is done.
    I would like to pass information from asp page(microsoft server pages) to the portal and extract the information in the portal
    I know how to how to pass the the information as POST or GET method
    but how do I extract the infomation within an iView ?
    and what is the portal URL I need to call from the asp page ? a page URL or an iView URL ?
    Thanks
    Y.R

    Hi,
    In order to use an ASP application in the portal u have to first create a system. In the System Definition Properties, give the url of your ASP page in the Name of server field and the name of the ASP page in the URI field.
    For more clear understanding, please go through the following document
    http://help.sap.com/bestpractices/crossindustry/enterpriseportal/v160/documentation/How-to_Guides/25_HowToUseAppIntegrator_en.pdf
    Best Regards
    Priya

  • Passing information from JClient to View Object

    What would be best way to pass information from JClient to View Object. I would like to implement security system, where view object would take information about what specific users can do (not oracle users, I would like to have one user to connect to database only) from an oracle table or stored procedure. Now I need to pass information about user: user name, IP, application etc. to View Object. I have two ideas for possible solution:
    a) dynamic attributes
    b) exporting methods (with custom interface)
    Any suggestions ?
    Todi

    What would be best way to pass information from JClient to View Object. I would like to implement security system, where view object would take information about what specific users can do (not oracle users, I would like to have one user to connect to database only) from an oracle table or stored procedure. Now I need to pass information about user: user name, IP, application etc. to View Object. I have two ideas for possible solution:
    a) dynamic attributesPreferable if you need to store per row information that's dynamic/required for client.
    b) exporting methods (with custom interface)Preferable if it's a one time setup kind of information. Though even that can be achieved by the dynamic attributes.

  • Passing Information From Socket to GUI

    Hi, I'm making a chat client, but I'm having trouble passing information from server's input stream to my GUI. I made two threads, one for sending and one for receiving, and I start them both when I click "connect" after I log in to the server. So what happens is I run my program, the frame appears as I want it to, and then I click connect, and after a little wait the button "unclicks" (or w/e) and nothing happens. I don't know why I am not receiving the messages from the server. If I make the program "GUI-less" it works, I can both send and receive messages via the console. But in the GUI, where I am sending/receiving via my two TextAreas, it doesn't work. Here's my code:
    (I apologize ahead of time for posting so much code in a thread, I tried to cut it down as best as I could.)
    BotWindow class (GUI) - Action Listeners
    public void createProps() {
            outText.setLineWrap(true);  //Text Areas
            outText.setForeground(Color.white);
            outText.setBackground(Color.blue);
            outText.setEditable(false);
            inText.setLineWrap(true);
            inText.setForeground(Color.white);
            connect.addActionListener(this);    //Action Listeners
            disc.addActionListener(this);
            submit.addActionListener(this);
    BotWindow class (GUI) - actionPerformed for connect/disc
    public void actionPerformed(ActionEvent evt) {
            JButton src = (JButton)evt.getSource();
            if(src == connect) {
                try {
                    bnet = new BattleNet("useast.battle.net");
                    bnet.logIn("dynobot1", "test");
                catch(Exception error) {
                    System.out.println(error);
            if(src == disc) {
                try {
                    BattleNet bnet = new BattleNet("useast.battle.net");
                    bnet.logOut();
                catch(Exception error) {
                    System.out.println(error);
    BattleNet class
    import java.io.*;
    import java.net.*;
    public class BattleNet extends SendAndReceive {
        Socket sock;
        InputStream in;
        OutputStream out;
        Send send;
        Receive receive;
        public BattleNet(String server) {
            try {
                sock = new Socket(server, 6112);
                in = sock.getInputStream();
                out = sock.getOutputStream();
                send = new Send(this.out);
                receive = new Receive(this.in);
            catch(Exception error) {
                System.out.println(error);
        public void logIn(String username, String password) {
            byte[] u = username.getBytes();
            byte[] p = password.getBytes();
            try {
                out.write((byte) 0x03);
                out.write((byte) 0x04);
                out.write(u);
                out.write((byte) 0x0a);
                out.write(p);
                out.write((byte) 0x0a);
                receive.start();
                send.start();
            catch(IOException e) {
                System.out.println(e);
        public void logOut() {
            try {
                sock.close();
                in.close();
                out.close();
            catch(Exception error) {
                System.out.println(error);
    SendAndReceive class (with Threads as subclasses)
    import java.io.*;
    import java.net.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SendAndReceive implements ActionListener {
        JButton src = null; 
        public SendAndReceive() {} 
        public void actionPerformed(ActionEvent evt) {
            src = (JButton)evt.getSource();
    class Send extends Thread {
        OutputStream out;
        SendAndReceive sr = new SendAndReceive();
        BotWindow bw = new BotWindow();
        public Send(OutputStream inputOut) {
            out = inputOut;
        public void run() {
            if(sr.src == bw.submit) {
                String newLine = "\n";
                String messageOut = bw.inText.getText();
                bw.outText.setText(bw.outText.getText() + newLine + messageOut);
                byte[] m = messageOut.getBytes();
                try {
                    out.write((byte) 0x05);
                    out.write(m);
                catch(IOException e) {
                    System.out.println(e);
                String blank = "";
                bw.inText.setText(blank);
                sr.src = null;
    class Receive extends Thread {
        InputStream in;
        SendAndReceive sr = new SendAndReceive();
        BotWindow bw;
        public Receive(InputStream inputIn) {
            in = inputIn;
            bw = new BotWindow();
        public void run() {
            while(true) {  //thinking of doing while(sr.src != bw.submit)
                try {
                    bw.outText.setText(bw.outText.getText() + (char)in.read());
                catch(IOException e) {
                    System.out.println(e);
    }So, to repeat my question, why isn't my GUI receiving the data being passed to it from the BattleNet socket? Also, am I taking the right approach on separating the send and receive methods and is my threading correct?

    Just Look at this code...
    while(true) {  //thinking of doing while(sr.src != bw.submit)
    try {
    bw.outText.setText(bw.outText.getText() + (char)in.read());
    catch(IOException e) {
    System.out.println(e);
    The problematic area is this code itself.
    Try to read text Line by Line basis. You can do this by using readLine() rather than read().
    The modified code should be like this:
    while(true) {  //thinking of doing while(sr.src != bw.submit)
    try {
    String TextRead=in.readLine();
    String Prev_text=bw.outText.getText();
    String new_Text=Prev_text + new_Text;
    bw.outText.setText(new_Text);
    catch(IOException e) {
    System.out.println(e);
    This would make the code easy to read and modify.
    I have faced these kindaa problems during my JAVA project coding. However they have been solved by using a much simpler approach like the one I have used. Although they do the same thing, but anyhow it provides a better result for reasons quite unknown to me!!!

  • Passing Information From Server to GUI

    Hi, I'm making a chat client, but I'm having trouble passing information from server's input stream to my GUI. I made two threads, one for sending and one for receiving, and I start them both when I click "connect" after I log in to the server. So what happens is I run my program, the frame appears as I want it to, and then I click connect, and after a little wait the button "unclicks" (or w/e) and nothing happens. I don't know why I am not receiving the messages from the server. If I make the program "GUI-less" it works, I can both send and receive messages via the console. But in the GUI, where I am sending/receiving via my two TextAreas, it doesn't work. Here's my code:
    (I apologize ahead of time for posting so much code in a thread, I tried to cut it down as best as I could.)
    actionPerformed method for connect and disconnect buttons (in BotWindow class)
    public void actionPerformed(ActionEvent evt) {
            JButton src = (JButton)evt.getSource();
            if(src == connect) {
                try {
                    bnet = new BattleNet("useast.battle.net");
                    bnet.logIn("dynobot1", "test");
                catch(Exception error) {
                    System.out.println(error);
            if(src == disc) {
                try {
                    BattleNet bnet = new BattleNet("useast.battle.net");
                    bnet.logOut();
                catch(Exception error) {
                    System.out.println(error);
    BattleNet class
    import java.io.*;
    import java.net.*;
    public class BattleNet extends SendAndReceive {
        Socket sock;
        InputStream in;
        OutputStream out;
        Send send;
        Receive receive;
        public BattleNet(String server) {
            try {
                sock = new Socket(server, 6112);
                in = sock.getInputStream();
                out = sock.getOutputStream();
                send = new Send(this.out);
                receive = new Receive(this.in);
            catch(Exception error) {
                System.out.println(error);
        public void logIn(String username, String password) {
            byte[] u = username.getBytes();
            byte[] p = password.getBytes();
            try {
                out.write((byte) 0x03);
                out.write((byte) 0x04);
                out.write(u);
                out.write((byte) 0x0a);
                out.write(p);
                out.write((byte) 0x0a);
                receive.start();
                send.start();
            catch(IOException e) {
                System.out.println(e);
        public void logOut() {
            try {
                sock.close();
                in.close();
                out.close();
            catch(Exception error) {
                System.out.println(error);
    SendAndReceive class (with Threads as subclasses)
    import java.io.*;
    import java.net.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SendAndReceive implements ActionListener {
        JButton src = null; 
        public SendAndReceive() {} 
        public void actionPerformed(ActionEvent evt) {
            src = (JButton)evt.getSource();
    class Send extends Thread {
        OutputStream out;
        SendAndReceive sr = new SendAndReceive();
        BotWindow bw = new BotWindow();
        public Send(OutputStream inputOut) {
            out = inputOut;
        public void run() {
            if(sr.src == bw.submit) {
                String newLine = "\n";
                String messageOut = bw.inText.getText();
                bw.outText.setText(bw.outText.getText() + newLine + messageOut);
                byte[] m = messageOut.getBytes();
                try {
                    out.write((byte) 0x05);
                    out.write(m);
                catch(IOException e) {
                    System.out.println(e);
                String blank = "";
                bw.inText.setText(blank);
                sr.src = null;
    class Receive extends Thread {
        InputStream in;
        SendAndReceive sr = new SendAndReceive();
        BotWindow bw;
        public Receive(InputStream inputIn) {
            in = inputIn;
            bw = new BotWindow();
        public void run() {
            while(true) {
                try {
                    bw.outText.setText(bw.outText.getText() + (char)in.read());
                catch(IOException e) {
                    System.out.println(e);
    }So, to repeat my questions, SendAndReceive class, but I'm not sure if this is the right approach.why isn't my TextArea (BotWindow.outText) not receiving and setting it's text to the information from the server? Is my threading correct? Also, with the way I set up the threads, will the Send function be able to send in the midst of the receive function? I tried to set it up so that it could by implementing ActionListener in my SendAndReceive class, but I am not sure if this is the correct approach.
    P.S. The reason I put this in Swing is because it works without a GUI/Swing components! If it will help, I will post the GUI-less program I made that works.

    Multi-post. Reply to this posting: http://forum.java.sun.com/thread.jspa?threadID=656211

  • Passing Parameters via Post Method from Webdynpro Java to a web application

    Hello Experts,
    I want to pass few parameters from a web dynpro application to an external web application.
    In order to achieve this, I am referring to the below thread:
    HTTP Post
    As mentioned in the thread, I am trying to create an additional Suspend Plug parameter (besides 'Url' of type String) with name 'postParams' and of type Map.
    But when I build my DC, I am getting the same error which most of the people in the thread have mentioned:
    Controller XXXCompInterfaceView [Suspend]: Outbound plug (of type 'Suspend') 'Suspend' may have at most two parameters: 'Url' of type 'string' and 'postParams' of type 'Map'.
    I am using SAP NetWeaver Developer Studio Version: 7.01.00
    Kindly suggest if this is the NWDS version issue or is it something else that I am missing out.
    Also, if it is the NWDS version issue please let me know the NWDS version that I can use to avoid this error.
    Any other suggestion/alternative approach to pass the parameters via POST method from webdynpro java to an external web application apart from the one which is mentioned in the above thread is most welcome.
    Thanks & Regards,
    Anurag

    Hi,
    This is purely a java approach, even you can try this for your requirement.
    There are two types of http calls synchronous call or Asynchronous call. So you have to choose the way to pass parameters in post method based on the http call.
    if it is synchronous means, collect all the values from users/parameters using UI element eg: form and pass all the values via form to the next page is nothing but your web application url.
    If it is Asynchronous  means, write a http client in java and integrate the same with your custom code and you can find an option for sending parameters in post method.
    here you go and find the way to implement Asynchronous  scenario,
    http://www.theserverside.com/news/1365153/HttpClient-and-FileUpload
    http://download.oracle.com/javase/tutorial/networking/urls/readingWriting.html
    http://digiassn.blogspot.com/2008/10/java-simple-httpurlconnection-example.html
    Thanks & Regards
    Rajesh A

  • HT201250 how can i pass information from one mac to another mac by using the time capsule

    how can i pass information from one mac to another mac by using the time capsule

    If you want to transfer files, settings, etc., you must open Migration Assistant (Applications > Utilities) in the Mac that you want to transfer the files and follow the instructions

  • Calling static synchronized method in the constructor

    Is it ok to do so ?
    (calling a static synchronized method from the constructor of the same class)
    Please advise vis-a-vis pros and cons.
    regards,
    s.giri

    I would take a different take here. Sure you can do it but there are some ramifications from a best practices perspective. f you think of a class as a proper object, then making a method static or not is simple. the static variables and methods belong to the class while the non-static variables and methods belong to the instance.
    a method should be bound to the class (made static) if the method operates on the class's static variables (modifies the class's state). an instance object should not directly modify the state of the class.
    a method should be bound to the instance (made non-static) if it operates on the instance's (non-static) variables.
    you should not modify the state of the class object (the static variables) within the instance (non-static) method - rather, relegate that to the class's methods.
    although it is permitted, i do not access the static methods through an instance object. i only access static methods through the class object for clarity.
    and since the instance variables are not part of the class object itself, the language cannot and does not allow access to non-static variables and methods through the class object's methods.

Maybe you are looking for

  • How do I reset my hard drive software to Snow Leopard?

    When I bought my 2009 MacBook, it was Snow Leopard, but it seems to lag now that it is on Lion. How do I reset my software?

  • Can we release the standard price for a material whose Price control is "V"

    Hi experts, Could you please clarify my doubt that can we release the standard cost of a material whose price control is "V". Our user is trying to release the std price. But its not getting released. If the material is of ML relevant I could have ch

  • Adding a doubleclick event on Inline Graphic Image

    Hello all, I'm trying to add a doubleClickEvent to an InlineGraphicElement, so that a popup window appears, and I can enter a new width and height. I'm having trouble adding a listener for the doubleClick event to an image that I'm about to add as an

  • How to change Selection Criteria for a Business Content Data Source

    Hi Experts I am extracting data using 0CO_OM_CCA_9 Datasource. I would like to be able to select a range of Company Code (BUKRS) to pull in, but I cannot find a way to make certain fields available as selection criteria. When I go into "Change DataSo

  • PHP, MYSQL, INTERACTIVE EXCEL

    Hello, Im looking to give an end user the ablity to upload an excel document by some sort of browse/add file button in order to change content on a page.  Basically on a weekly basis the user will upload an excel document with the weeks scores and re