Changes

Jump to navigation Jump to search
592 bytes added ,  14:08, 19 April 2022
m
Line 3: Line 3:  
===With apt===
 
===With apt===
 
  <nowiki>sudo apt-add-repository ppa:webupd8team/java
 
  <nowiki>sudo apt-add-repository ppa:webupd8team/java
            sudo apt-get update
+
            sudo apt-get update
            sudo apt-get install oracle-java8-installer</nowiki>
+
            sudo apt-get install oracle-java8-installer</nowiki>
    
Also ensure your JAVA_HOME variable has been set to:
 
Also ensure your JAVA_HOME variable has been set to:
Line 404: Line 404:  
==Interfaces==
 
==Interfaces==
 
If you whant to define a method for more than one class, you should use an interface (rigt click on project > new > interface)<br />
 
If you whant to define a method for more than one class, you should use an interface (rigt click on project > new > interface)<br />
Interfaces file names should start with upper case.<br />
+
Interfaces file names should start with upper case.<syntaxhighlight lang="java">
 +
public interface GamingConsole {
 +
    public void up();
 +
    public void down();
 +
    public void left();
 +
    public void right();
 +
}
 +
 
 +
public class MarioGame implements GamingConsole {
 +
    @Override
 +
    public void up() {
 +
        System.out.println("Jump");
 +
    }
 +
 
 +
    @Override
 +
    public void down() {
 +
        System.out.println("Goes into a hole");   
 +
    }
 +
 
 +
    @Override
 +
    public void left() {
 +
        System.out.println("Go back");   
 +
    }
 +
 
 +
    @Override
 +
    public void right() {
 +
        System.out.println("Go forward");   
 +
    }
 +
}
 +
</syntaxhighlight><br />
 
Example files:<br />
 
Example files:<br />
 
[https://github.com/rafahsolis/javaTutorial/blob/master/interfaces.java interfaces.java]<br />
 
[https://github.com/rafahsolis/javaTutorial/blob/master/interfaces.java interfaces.java]<br />

Navigation menu