Bon WE a tous,

Le code ci dessous m indique une erreur au niveau system.out....

Quelqu'un pourrait-il m'eclairer


Habiler

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
import java.time.*;
/**
 *
 * @author hab
 */
public class NewClass1 {
LocalDate endofCentury = LocalDate.of(2014, 01, 01);
LocalDate now = LocalDate.now();
 
Period diff = Period.between(endofCentury, now);
 
System.out.println("Difference is %d years, %d months and %d days old", 
                    diff.getYears(), diff.getMonths(), diff.getDays());

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
 
Compiling 5 source files to C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\build\classes
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:13: error: <identifier> expected
System.out.println("Difference is %d years, %d months and %d days old", 
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:13: error: illegal start of type
System.out.println("Difference is %d years, %d months and %d days old", 
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:14: error: <identifier> expected
                    diff.getYears(), diff.getMonths(), diff.getDays());
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:14: error: ';' expected
                    diff.getYears(), diff.getMonths(), diff.getDays());
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:14: error: illegal start of type
                    diff.getYears(), diff.getMonths(), diff.getDays());
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:14: error: ';' expected
                    diff.getYears(), diff.getMonths(), diff.getDays());
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:14: error: invalid method declaration; return type required
                    diff.getYears(), diff.getMonths(), diff.getDays());
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\src\NewClass1.java:14: error: ';' expected
                    diff.getYears(), diff.getMonths(), diff.getDays());
8 errors
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\nbproject\build-impl.xml:954: The following error occurred while executing this line:
C:\Users\hab\Documents\NetBeansProjects\GUIFormExamples\JavaApplication29\nbproject\build-impl.xml:294: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)