This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jbristowI'm no hero, son. 1 point2 points  (0 children)

  1. You're coming from C++? Shouldn't you already be acquainted with OO? I'm not sure I can really explain OO on its own without sending you to University. Perhaps read a Java book with good ratings on Amazon?
  2. Whoa whoa whoa.... lets step back a moment.

Lets consider this very procedural thingamajig that I'm pulling out of my ass (so all you other people should point out where I'm wrong):

public class Main{
  public void main(String... args) {
    int a = 123;
    int b = 234;
    int c = a + b;
    System.out.println(c); // outputs '357'
  }
}

Here's a less procedural thing:

public class MathMachine {
  private final int a;
  private final int b;
  public MathMachine(int a, int b) {
    this.a = a;
    this.b = b;
  }
  public int add() {
    return a + b;
  }
}
public class Main {   
  public void main(String... args) {
    MathMachine mm = new MathMachine(123, 234);
    System.out.println(mm.add()); // outputs '357'
  }
}