This shows you the differences between two versions of the page.
java:classes:extends [2013/04/26 09:51] 88.75.157.182 created |
java:classes:extends [2024/02/16 01:03] (current) |
||
---|---|---|---|
Line 3: | Line 3: | ||
<code java> | <code java> | ||
- | package meine.mydate; | + | package myclass.mydate; |
import java.util.Date; | import java.util.Date; | ||
Line 29: | Line 29: | ||
</code> | </code> | ||
+ | |||
+ | |||
+ | ==== usage of the extended class ==== | ||
+ | <code java> | ||
+ | |||
+ | package xmascalc; | ||
+ | |||
+ | |||
+ | import myclasses.mydate.MyDate; // import the class MyDate | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | public class XmasCalc{ | ||
+ | |||
+ | /** | ||
+ | * @param args the command line arguments | ||
+ | */ | ||
+ | public static void main(String[] args) { | ||
+ | // TODO code application logic here | ||
+ | |||
+ | |||
+ | MyDate my = new MyDate(); | ||
+ | int year = my.getFullYear(); | ||
+ | System.out.println(year); | ||
+ | |||
+ | |||
+ | int month = my.getMonth(); | ||
+ | System.out.println(month); | ||
+ | |||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | </code> | ||
+ | |||
+ | |||
+ | === output === | ||
+ | 2013 | ||
+ | 99 |