Results 1 to 4 of 4
  1. #1
    mcnikal is offline Member
    Join Date
    Mar 2014
    Posts
    13
    Rep Power
    0

    Default BlueJ-Creating new variable from within a method

    Hello,

    This is probably a stupid question, but I am using blueJ as my java editor.

    If I have a method that creates a new variable (the name of which is a string argument for the method). Can I get that variable to appear in the workspace in the variables pane?

    So instead of just using return to output the variable how do I get in that variables pane?

    Thanks

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,587
    Rep Power
    25

    Default Re: BlueJ-Creating new variable from within a method

    If I have a method that creates a new variable
    Not sure I understand what you mean. The programmer creates variables by typing them into the code. Are you asking about a variable that is defined local to a method?

    What is "the workspace in the variables pane"? Can you post some java code that shows what you are trying to do?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    mcnikal is offline Member
    Join Date
    Mar 2014
    Posts
    13
    Rep Power
    0

    Default Re: BlueJ-Creating new variable from within a method

    Yes so a variable that is created within a method, but when the method is ran becomes available outside the method.

    I haven't got any code that works for what I'm trying to do. I'll try and get something that is sort of representative.

    The workspace is where I enter test my code. Creating new objects and sending messages etc to them.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,587
    Rep Power
    25

    Default Re: BlueJ-Creating new variable from within a method

    a variable that is created within a method, but when the method is ran becomes available outside the method.
    A variable defined in a method goes away when the method exits. It only exists while the method is executing.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 1
    Last Post: 04-21-2012, 07:03 PM
  2. Replies: 4
    Last Post: 04-02-2012, 02:50 PM
  3. Replies: 2
    Last Post: 03-23-2012, 05:53 AM
  4. Replies: 1
    Last Post: 10-27-2011, 08:16 AM
  5. Replies: 18
    Last Post: 04-18-2011, 06:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •