This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
java:local_inner_classes [2017/04/03 00:25] gthanos [Πρόσβαση στις τοπικές μεταβλητές της μεθόδου] |
java:local_inner_classes [2021/04/12 05:54] gthanos [Τοπικές κλάσεις] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Τοπικές κλάσεις ====== | ====== Τοπικές κλάσεις ====== | ||
| + | |||
| Μπορείτε να ορίσετε μία κλάση μέσα σε οποιοδήποτε μπλοκ κώδικα, | Μπορείτε να ορίσετε μία κλάση μέσα σε οποιοδήποτε μπλοκ κώδικα, | ||
| Line 7: | Line 8: | ||
| Δείτε το παρακάτω παράδειγμα κώδικα. | Δείτε το παρακάτω παράδειγμα κώδικα. | ||
| - | <code java LocalClassExample.java> | + | <code java ValidatePhoneNumberUsingLocalClass.java> |
| - | public class LocalClassExample | + | |
| + | public class ValidatePhoneNumberUsingLocalClass | ||
| | | ||
| static String regularExpression = " | static String regularExpression = " | ||
| | | ||
| - | public static void validatePhoneNumber(String | + | public static void validatePhoneNumber(String |
| | | ||
| final int numberLength = 10; | final int numberLength = 10; | ||
| Line 48: | Line 50: | ||
| // myNumber1.printOriginalNumbers(); | // myNumber1.printOriginalNumbers(); | ||
| - | System.out.println(number1 | + | System.out.println(number |
| - | System.out.println(number2 + ": " + new PhoneNumber(number2)); | + | |
| } | } | ||
| public static void main(String... args) { | public static void main(String... args) { | ||
| - | | + | |
| + | ValidatePhoneNumberUsingLocalClass.validatePhoneNumber(" | ||
| } | } | ||
| } | } | ||
| Line 74: | Line 76: | ||
| </ | </ | ||
| - | |Προηγούμενο: | + | |Προηγούμενο: |