Parameters
The variables passed as method's parameters has to
match the type.

package com.minte9.basics.variables;
public class Parameters {
public static void main(String[] args) {
Math math = new Math();
int sum = math.sum(1,2);
System.out.println(
"Sum(1,2) = " + sum
);
}
}
class Math {
public int sum(int n1, int n2) {
return n1 + n2;
}
}
Default values
Object instance variables
always get a default value.

package com.minte9.basics.variables;
public class DefaultValues {
public static void main(String[] args) {
new Values().showValues();
}
}
class Values {
int a;
float b;
boolean c;
Values v;
public void showValues() {
String local_variable = "a";
System.out.println("int a = " + a);
System.out.println("float b = " + b);
System.out.println("boolean c = " + c);
System.out.println("object v = " + v);
System.out.println("String local_var = " + local_variable);
}
}
Pass by value
Variables in Java are passed by value (a copy),
not by reference.

package com.minte9.basics.variables;
public class PassedByValue {
public static void main(String[] args) {
int x = 7;
int z = x;
System.out.println("x == z " + (x == z));
z = 0;
System.out.println("z changed / x doesn't change");
System.out.println("x != z " + (x != z));
}
}
Setter
Setter and getter
naming convention are an important Java standard.

package com.minte9.basics.variables;
public class Setter {
public static void main(String[] args) {
Dog dog = new Dog();
dog.setName("Rex");
System.out.println(dog.getName());
}
}
class Dog {
private String name;
public void setName(String x) {
name = x;
}
public String getName() {
return name;
}
}