Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: Java

  1. #11

    Default

    Code:
    package lab1; /* This identifies what package this file belongs too */
    import java.util.Scanner; /** Import the scanner class from the java standard library */
    
    
    /**
    * @author Sarah Bermudez
    * October 9, 2009
    * The purpose of the program is to calculate a formula by assigning a
    * value to each variable.
    */
    public class Main { /* definition of main class, with public visibility */
    /**
    * @param args the command line arguments   //javadoc
    */
    public static void main(String[] args) { //execution entry
    int i, j; /* declare 2 integer variables named i and j */
    
    char c; // declare character variable named c
    double x; // declare double variable named x
    
    /**
    * assign values to the variables
    */
    i = 4; 
    j = i + 7; 
    c = 'A'; 
    x = 9.087; 
    x = x * 12.3; 
    
    System.out.println("i is " + i + ", j is " + j + ", c is " + c + ", x is " + x); //write to system output
    
    } // end of execution
    
    }//end of Main class definition
    Here's how I would do it.
    Last edited by phantasm; 10-09-2009 at 11:29 PM.

  2. #12

    Default

    That's cool phantasm but what does all of that mean? Lol.

    Thanks for the explanation, Cel.
    Love is a conversation without end which leads to the silence of eternity.

  3. #13

    Default

    I think you should be learning this from your well paid instructor, not from me.

  4. #14

    Default

    I think I should be too but sadly she's in China and told us to do a hunt and find. I'm probably going ahead of what I needed to do but I like to learn what I'm trying to find.

    Even though this thread is about asking for someone to help me out. Why even bother with all of that if you didn't want to explain it in the first place? >.>;;
    Love is a conversation without end which leads to the silence of eternity.

  5. #15

    Default

    Is there anything in that program that still doesn't make sense to you or you want clarification on? I'm a .NET guy myself (mostly C#), but it's pretty close to java, and I do develop java on occasion for one client (as well as having a java developer housemate).

    Specifically what part don't you understand the meaning of?

  6. #16

    Default

    I guess I'm having trouble understanding intergers, variables and values. I thought variables and values were interchangeable so I don't know why you would have to assign a value to a variable if you can just change the variable. I don't even know if what I just said made sense. Lol. Man, I feel dumb and usually I pick up on this stuff pretty fast.

    Is this similar to understanding algebra? It would seem so but I don't want to put myself in that mindset and fuck myself over by using the same definitions.
    Love is a conversation without end which leads to the silence of eternity.

  7. #17

    Default

    When you say:
    int i;
    You're asking the computer to reserve enough space for an integer in memory, and to call that space "i". That reserved space does not yet have a value (although it'll likely default to 0). So that variable, i, is currently unassigned.

    When you assign a value to i, it stores that value in the space in memory reserved for i. So by saying i = 4, you place "4" in that space. The variable is still i, but the value is now 4. That value can be changed, but the variable is still named i.

    So one way to think of it is that the variable is the bucket, and the value is the contents.

    When you later say something like:
    j = i + 7
    You're actually saying j equals the value of i plus seven.

    That clarify it a bit?
    Last edited by Celephais; 10-10-2009 at 03:18 PM.

  8. #18

    Default

    Cel, thank you SO much. I get it now. You're awesome!
    Love is a conversation without end which leads to the silence of eternity.

  9. #19

    Default

    Just wait until you have to parse a complex unverified XML file with DOM.
    Why are you learning to code?
    It takes a person that is really fucked in the head to enjoy this shit.

    EDIT: Sorry, I'm apparently terrible at explaining things, I was 100% sure my comments on your code would explain it completely.
    Last edited by phantasm; 10-10-2009 at 11:41 PM.

Similar Threads

  1. Java
    By Allycat in forum Off-Topic
    Replies: 6
    Last Post: 01-13-2005, 10:42 AM
  2. Java == PWNED!1!!
    By Soulpieced in forum Off-Topic
    Replies: 24
    Last Post: 03-25-2004, 06:53 PM
  3. Java Help Requested!
    By GSLeloo in forum Off-Topic
    Replies: 25
    Last Post: 01-11-2004, 03:07 PM

Posting Permissions

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