Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Methods
- {
- private int x;
- public static void hello()
- {
- System.out.println("Hello, world!");
- }
- public void print()
- {
- System.out.println("x is: "+x);
- }
- public void setX(int x)
- {
- this.x=x;
- }
- public Methods(int x)
- {
- setX(x);
- }
- public int getX()
- {
- return this.x;
- }
- static void print(Methods m)
- {
- m.print();
- }
- public static void main(String[] args)
- Methods m = new Methods(42);
- hello();
- m.print();
- m.setX(34);
- System.out.println("m.getX: " + m.getX());
- print(m);
- }
- Methods.java:28: error: ';' expected
- public static void main(String[] args)
- ^
- Methods.java:31: error: invalid method declaration; return type required
- hello();
- ^
- Methods.java:32: error: <identifier> expected
- m.print();
- ^
- Methods.java:33: error: <identifier> expected
- m.setX(34);
- ^
- Methods.java:33: error: illegal start of type
- m.setX(34);
- ^
- Methods.java:34: error: <identifier> expected
- System.out.println("m.getX: " + m.getX());
- ^
- Methods.java:34: error: illegal start of type
- System.out.println("m.getX: " + m.getX());
- ^
- Methods.java:35: error: invalid method declaration; return type required
- print(m);
- ^
- Methods.java:35: error: <identifier> expected
- print(m);
- ^
- 9 errors
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement