# Tiemen

Members

6

## Tiemen's Achievements

0

### Reputation

Thank you for taking the time to explain. The Method overload is not completely clear, but I have a feeling I'll get it later when I just do the rest of the tutorial and exercises.

This code below clarifies some part of my confusion in the first part of my question. But the second and 3th question remains. public class MyClass { public static void main(String[] args) { // Code here CANNOT use x { // This is a block // Code here CANNOT use x int x = 100; // Code here CAN use x System.out.println(x); } // The block ends here // Code here CANNOT use x } }

So in the example below they want to give a example that multiple methods can have the same name with different parameters: I have a few questions: I thought variables had unique names, how does it knows we talk about the same x + y. I assume the variables are only defined within the method then, right? And not within the whole public class MyClass Second: Why does the double return the value 10.5599999999999 instead of 10.56 If I edit 6.26 to 6.27 it will return 10.57 public class MyClass { static int plusMethodInt(int x, int y) { return x + y; } static double plusMethodDouble(double x, double y) { return x + y; } public static void main(String[] args) { int myNum1 = plusMethodInt(8, 5); double myNum2 = plusMethodDouble(4.3, 6.26); System.out.println("int: " + myNum1); System.out.println("double: " + myNum2); } } Result: int: 13 double: 10.559999999999999 Third Why call the method the same if your using different types of variables. Will those variables called x be usable if you call on x and there is a value int 2 and float 4.21 Example in tutorial. int myMethod(int x) float myMethod(float x) double myMethod(double x, double y) Thank you
4. ## Can't run MyClass.java via Command Prompt (cmd.exe) in the "java getting started" tutorial

Haha, ok. Thank you. I was afraid it was something simple.
5. ## Can't run MyClass.java via Command Prompt (cmd.exe) in the "java getting started" tutorial

I tried it in Eclipse, that seems to work.
6. ## Can't run MyClass.java via Command Prompt (cmd.exe) in the "java getting started" tutorial

Hi, I am starting to learm Java(first language). I am having trouble starting up. I try to run my first line of code. But it gives an error. I know the existense of command Prompt but I don't know how to use it. Can somone help me out? Thanks
×
×
• Create New...