File tree Expand file tree Collapse file tree 8 files changed +163
-0
lines changed
src/main/java/org/java10/examples Expand file tree Collapse file tree 8 files changed +163
-0
lines changed Original file line number Diff line number Diff line change
1
+ # ## Maven
2
+ target /
3
+
4
+ pom.xml.tag
5
+ pom.xml.releaseBackup
6
+ pom.xml.versionsBackup
7
+ pom.xml.next
8
+ release.properties
9
+ dependency-reduced-pom.xml
10
+ buildNumber.properties
11
+ .mvn /timing.properties
12
+ ! /.mvn /wrapper /maven-wrapper.jar
13
+
14
+ # ## Java
15
+
16
+ * .class
17
+ * .log
18
+ * .ctxt
19
+ .mtj.tmp /
20
+ * .jar
21
+ * .war
22
+ * .ear
23
+ * .zip
24
+ * .tar.gz
25
+ * .rar
26
+ hs_err_pid *
27
+
28
+ # ## Intellij
29
+
30
+ .idea
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <module type =" JAVA_MODULE" version =" 4" />
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5
+ <modelVersion >4.0.0</modelVersion >
6
+
7
+ <groupId >org.java10.examples</groupId >
8
+ <artifactId >Java10Examples</artifactId >
9
+ <version >1.0-SNAPSHOT</version >
10
+
11
+ <properties >
12
+ <maven .compiler.source>10</maven .compiler.source>
13
+ <maven .compiler.target>1.10</maven .compiler.target>
14
+ </properties >
15
+
16
+ <build >
17
+ <plugins >
18
+ <plugin >
19
+ <groupId >org.apache.maven.plugins</groupId >
20
+ <artifactId >maven-compiler-plugin</artifactId >
21
+ <version >3.7.0</version >
22
+ <configuration >
23
+ <jdkToolchain >
24
+ <version >${java.version} </version >
25
+ </jdkToolchain >
26
+ </configuration >
27
+ <dependencies >
28
+ <dependency >
29
+ <groupId >org.ow2.asm</groupId >
30
+ <artifactId >asm</artifactId >
31
+ <version >6.0_ALPHA</version >
32
+ </dependency >
33
+ </dependencies >
34
+ </plugin >
35
+ </plugins >
36
+ </build >
37
+
38
+ </project >
Original file line number Diff line number Diff line change
1
+ package org .java10 .examples ;
2
+
3
+ public class BasicExample {
4
+
5
+ public static void main (String [] args ) {
6
+ var i = 0 ;
7
+
8
+ System .out .println (i );
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ package org .java10 .examples ;
2
+
3
+ public class ComplexObjectExample {
4
+
5
+ public static void main (String [] args ) {
6
+
7
+ }
8
+
9
+ }
Original file line number Diff line number Diff line change
1
+ package org .java10 .examples ;
2
+
3
+ import java .time .LocalDate ;
4
+ import java .time .format .DateTimeFormatter ;
5
+
6
+ public class ObjectExample {
7
+
8
+ public static void main (String [] args ) {
9
+ var string = "This is a String" ;
10
+
11
+ var now = LocalDate .now ();
12
+
13
+ var formatter = DateTimeFormatter .ISO_DATE ;
14
+
15
+ System .out .println (string );
16
+ System .out .println (now .format (formatter ));
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ package org .java10 .examples ;
2
+
3
+ import org .java10 .examples .beans .Product ;
4
+
5
+ public class ProductExample {
6
+
7
+ public static void main (String [] args ) {
8
+ var modifiedProduct = new Product (8f , 0.5f ) {
9
+ public float applyInternetPrice () {
10
+ return getPrice () - 1f + getTax ();
11
+ }
12
+ };
13
+
14
+ System .out .println ("Modified product" );
15
+ System .out .println (modifiedProduct .calculateTotal ());
16
+ System .out .println (modifiedProduct .applyDiscount (0.15f ));
17
+ System .out .println (modifiedProduct .applyInternetPrice ());
18
+ System .out .println ("----------------" );
19
+
20
+ var commonProduct = new Product (8f , 0.5f );
21
+
22
+ System .out .println ("Common product" );
23
+ System .out .println (commonProduct .calculateTotal ());
24
+ System .out .println (commonProduct .applyDiscount (0.15f ));
25
+ System .out .println ("--------------" );
26
+ }
27
+
28
+ }
Original file line number Diff line number Diff line change
1
+ package org .java10 .examples .beans ;
2
+
3
+ public class Product {
4
+
5
+ private final float price ;
6
+ private final float tax ;
7
+
8
+ public Product (float price , float tax ) {
9
+ this .price = price ;
10
+ this .tax = tax ;
11
+ }
12
+
13
+ public float getPrice () {
14
+ return price ;
15
+ }
16
+
17
+ public float getTax () {
18
+ return tax ;
19
+ }
20
+
21
+ public float calculateTotal () {
22
+ return price + tax ;
23
+ }
24
+
25
+ public float applyDiscount (float discount ) {
26
+ return (price - (price * discount )) + tax ;
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments