BASE-4618: Create new module, local variable example
This commit is contained in:
parent
e459c3faa0
commit
6733ed715b
|
@ -0,0 +1,5 @@
|
|||
## Core Java Lang (Part 4)
|
||||
|
||||
This module contains articles about core features in the Java language
|
||||
|
||||
- TODO
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core-java-lang-4</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-lang-4</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>core-java-lang-4</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<assertj.version>3.19.0</assertj.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,22 @@
|
|||
package com.baeldung.finalkeyword;
|
||||
|
||||
public class LocalVariableFinal {
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (int i = 0; i < 1500; i++) {
|
||||
long startTime = System.nanoTime();
|
||||
String result = concatStrings();
|
||||
long totalTime = System.nanoTime() - startTime;
|
||||
if (i >= 500) {
|
||||
System.out.println(totalTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String concatStrings() {
|
||||
final String x = "x";
|
||||
final String y = "y";
|
||||
return x + y;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.baeldung.finalkeyword;
|
||||
|
||||
public class LocalVariableNonFinal {
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (int i = 0; i < 1500; i++) {
|
||||
long startTime = System.nanoTime();
|
||||
String result = concatStrings();
|
||||
long totalTime = System.nanoTime() - startTime;
|
||||
if (i >= 500) {
|
||||
System.out.println(totalTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String concatStrings() {
|
||||
String x = "x";
|
||||
String y = "y";
|
||||
return x + y;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue