Skip to content

Commit f55e2ea

Browse files
committed
BASE-4618: Create new module, local variable example
1 parent 56e2e3c commit f55e2ea

4 files changed

Lines changed: 91 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Core Java Lang (Part 4)
2+
3+
This module contains articles about core features in the Java language
4+
5+
- TODO
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
<artifactId>core-java-lang-4</artifactId>
8+
<version>0.1.0-SNAPSHOT</version>
9+
<name>core-java-lang-4</name>
10+
<packaging>jar</packaging>
11+
12+
<parent>
13+
<groupId>com.baeldung.core-java-modules</groupId>
14+
<artifactId>core-java-modules</artifactId>
15+
<version>0.0.1-SNAPSHOT</version>
16+
<relativePath>../</relativePath>
17+
</parent>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.assertj</groupId>
22+
<artifactId>assertj-core</artifactId>
23+
<version>${assertj.version}</version>
24+
<scope>test</scope>
25+
</dependency>
26+
</dependencies>
27+
28+
<build>
29+
<finalName>core-java-lang-4</finalName>
30+
<resources>
31+
<resource>
32+
<directory>src/main/resources</directory>
33+
<filtering>true</filtering>
34+
</resource>
35+
</resources>
36+
</build>
37+
38+
<properties>
39+
<assertj.version>3.19.0</assertj.version>
40+
</properties>
41+
42+
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.baeldung.finalkeyword;
2+
3+
public class LocalVariableFinal {
4+
5+
public static void main(String[] args) {
6+
for (int i = 0; i < 1500; i++) {
7+
long startTime = System.nanoTime();
8+
String result = concatStrings();
9+
long totalTime = System.nanoTime() - startTime;
10+
if (i >= 500) {
11+
System.out.println(totalTime);
12+
}
13+
}
14+
}
15+
16+
private static String concatStrings() {
17+
final String x = "x";
18+
final String y = "y";
19+
return x + y;
20+
}
21+
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.baeldung.finalkeyword;
2+
3+
public class LocalVariableNonFinal {
4+
5+
public static void main(String[] args) {
6+
for (int i = 0; i < 1500; i++) {
7+
long startTime = System.nanoTime();
8+
String result = concatStrings();
9+
long totalTime = System.nanoTime() - startTime;
10+
if (i >= 500) {
11+
System.out.println(totalTime);
12+
}
13+
}
14+
}
15+
16+
private static String concatStrings() {
17+
String x = "x";
18+
String y = "y";
19+
return x + y;
20+
}
21+
22+
}

0 commit comments

Comments
 (0)