Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Test
- {
- private int x;
- private String varNum;
- public Test()
- {
- varNum = "1234";
- }
- public String getVarNum()
- {
- return this.varNum;
- }
- // Main method
- public static void main(String[] args) {
- Test x = new Test();
- // Doesn't cause error, but nothing is printed
- x.getVarNum();
- // Doesn't cause error, but nothing is printed... again
- String myString = x.getVarNum();
- // Doesn't cause error, the value of varNum is printed
- System.out.println( x.getVarNum() );
- // Causes error - no semicolon at the end
- // x.getVarNum()
- // Causes error - no semicolon at the end... again
- // String anotherString = x.getVarNum()
- // Causes error - passed arguments inside methods cannot have a semicolon at the end
- // System.out.println( x.getVarNum(); );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment