Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Javascript (https://www.askmehelpdesk.com/forumdisplay.php?f=452)
-   -   Java (https://www.askmehelpdesk.com/showthread.php?t=672772)

  • Jun 19, 2012, 11:11 AM
    Midya
    java
    public class Over {
    public int stack(int j, int k) { return j + k; }
    public int stack(int m) {
    return m * m;
    }
    public int stack(float f) {
    return (int)f * 5;
    }
    public static void main(String args[]) {
    int n = 3;
    float f = 3;
    Over o = new Over();
    System.out.println("" + o.stack(n, n));
    System.out.println("" + o.stack(n));
    System.out.println("" + o.stack(f));
    }
    }
    what is Over o = new Over () do? What is happen if we don't use it?
  • Jun 19, 2012, 11:29 AM
    slapshot_oi
    Class definition:
    [CODE=Java]
    public class Over {
    public int stack(int j, int k) { return j + k; }
    public int stack(int m) {
    return m * m;
    }
    public int stack(float f) {
    return (int)f * 5;
    }
    public static void main(String args[]) {
    int n = 3;
    float f = 3;
    Over o = new Over();
    System.out.println("" + o.stack(n, n));
    System.out.println("" + o.stack(n));
    System.out.println("" + o.stack(f));
    }
    }[/CODE]

    This code
    [CODE=Java]Over o = new Over();[/CODE]
    Instantiates (creates in the heap of memory) an object of the class Over.

  • All times are GMT -7. The time now is 12:07 PM.