Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
Java
(view source)
Revision as of 13:55, 19 April 2022
145 bytes added
,
13:55, 19 April 2022
m
→Inheritance
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 370:
Line 370:
[https://github.com/rafahsolis/javaTutorial/blob/master/StringBuilderBufferFormatting.java example code]
[https://github.com/rafahsolis/javaTutorial/blob/master/StringBuilderBufferFormatting.java example code]
−
==Inheritance==
+
==Inheritance
& abstract
==
Use key word extends at the class declaration<br />
Use key word extends at the class declaration<br />
private variables and methods are not inherited.<br />
private variables and methods are not inherited.<br />
protected would be the appropiated declaration to be able to inherit variables without being public.
protected would be the appropiated declaration to be able to inherit variables without being public.
<source lang="java">
<source lang="java">
+
abstract class Machine {
+
abstract public void move();
+
}
+
public class Car extends Machine {
public class Car extends Machine {
+
public void move() {
+
System.out.println("Moving...")
+
}
}</source>
}</source>
sample code files:<br />
sample code files:<br />
Rafahsolis
Bureaucrats
,
Administrators
2,306
edits
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
Variants
Views
Read
View source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
Special pages
Printable version