Merge branch 'master' into master
This commit is contained in:
@@ -14,7 +14,5 @@
|
||||
- [Calculate Factorial in Java](https://www.baeldung.com/java-calculate-factorial)
|
||||
- [Find Substrings That Are Palindromes in Java](https://www.baeldung.com/java-palindrome-substrings)
|
||||
- [Find the Longest Substring without Repeating Characters](https://www.baeldung.com/java-longest-substring-without-repeated-characters)
|
||||
- [Java Two Pointer Technique](https://www.baeldung.com/java-two-pointer-technique)
|
||||
- [Permutations of an Array in Java](https://www.baeldung.com/java-array-permutations)
|
||||
- [Implementing Simple State Machines with Java Enums](https://www.baeldung.com/java-enum-simple-state-machine)
|
||||
- [Generate Combinations in Java](https://www.baeldung.com/java-combinations-algorithm)
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
- [Create a Sudoku Solver in Java](http://www.baeldung.com/java-sudoku)
|
||||
- [Displaying Money Amounts in Words](http://www.baeldung.com/java-money-into-words)
|
||||
- [A Collaborative Filtering Recommendation System in Java](http://www.baeldung.com/java-collaborative-filtering-recommendations)
|
||||
- [Converting Between Roman and Arabic Numerals in Java](http://www.baeldung.com/java-convert-roman-arabic)
|
||||
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
|
||||
- [An Introduction to the Theory of Big-O Notation](http://www.baeldung.com/big-o-notation)
|
||||
- [Check If Two Rectangles Overlap In Java](https://www.baeldung.com/java-check-if-two-rectangles-overlap)
|
||||
- [Calculate the Distance Between Two Points in Java](https://www.baeldung.com/java-distance-between-two-points)
|
||||
- [Find the Intersection of Two Lines in Java](https://www.baeldung.com/java-intersection-of-two-lines)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/target/
|
||||
.settings/
|
||||
.classpath
|
||||
.project
|
||||
@@ -0,0 +1,7 @@
|
||||
## Relevant articles:
|
||||
|
||||
- [Java Two Pointer Technique](https://www.baeldung.com/java-two-pointer-technique)
|
||||
- [Implementing Simple State Machines with Java Enums](https://www.baeldung.com/java-enum-simple-state-machine)
|
||||
- [Converting Between Roman and Arabic Numerals in Java](http://www.baeldung.com/java-convert-roman-arabic)
|
||||
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
|
||||
- [An Introduction to the Theory of Big-O Notation](http://www.baeldung.com/big-o-notation)
|
||||
@@ -0,0 +1,39 @@
|
||||
<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>algorithms-miscellaneous-3</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>algorithms-miscellaneous-3</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${org.assertj.core.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>${exec-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<org.assertj.core.version>3.9.0</org.assertj.core.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -4,3 +4,8 @@
|
||||
|
||||
### Relevant Articles:
|
||||
- [Set Operations in Java](http://www.baeldung.com/set-operations-in-java)
|
||||
- [HashSet and TreeSet Comparison](http://www.baeldung.com/java-hashset-vs-treeset)
|
||||
- [A Guide to HashSet in Java](http://www.baeldung.com/java-hashset)
|
||||
- [A Guide to TreeSet in Java](http://www.baeldung.com/java-tree-set)
|
||||
- [Initializing HashSet at the Time of Construction](http://www.baeldung.com/java-initialize-hashset)
|
||||
- [Guide to EnumSet](https://www.baeldung.com/java-enumset)
|
||||
@@ -4,14 +4,10 @@
|
||||
|
||||
### Relevant Articles:
|
||||
- [Java – Combine Multiple Collections](http://www.baeldung.com/java-combine-multiple-collections)
|
||||
- [HashSet and TreeSet Comparison](http://www.baeldung.com/java-hashset-vs-treeset)
|
||||
- [Collect a Java Stream to an Immutable Collection](http://www.baeldung.com/java-stream-immutable-collection)
|
||||
- [Introduction to the Java ArrayDeque](http://www.baeldung.com/java-array-deque)
|
||||
- [A Guide to HashSet in Java](http://www.baeldung.com/java-hashset)
|
||||
- [A Guide to TreeSet in Java](http://www.baeldung.com/java-tree-set)
|
||||
- [Getting the Size of an Iterable in Java](http://www.baeldung.com/java-iterable-size)
|
||||
- [How to Filter a Collection in Java](http://www.baeldung.com/java-collection-filtering)
|
||||
- [Initializing HashSet at the Time of Construction](http://www.baeldung.com/java-initialize-hashset)
|
||||
- [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element)
|
||||
- [Fail-Safe Iterator vs Fail-Fast Iterator](http://www.baeldung.com/java-fail-safe-vs-fail-fast-iterator)
|
||||
- [Shuffling Collections In Java](http://www.baeldung.com/java-shuffle-collection)
|
||||
@@ -23,7 +19,6 @@
|
||||
- [Time Complexity of Java Collections](https://www.baeldung.com/java-collections-complexity)
|
||||
- [Operating on and Removing an Item from Stream](https://www.baeldung.com/java-use-remove-item-stream)
|
||||
- [An Introduction to Synchronized Java Collections](https://www.baeldung.com/java-synchronized-collections)
|
||||
- [Guide to EnumSet](https://www.baeldung.com/java-enumset)
|
||||
- [Removing Elements from Java Collections](https://www.baeldung.com/java-collection-remove-elements)
|
||||
- [Combining Different Types of Collections in Java](https://www.baeldung.com/java-combine-collections)
|
||||
- [Sorting in Java](http://www.baeldung.com/java-sorting)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.baeldung.jvmannotations
|
||||
|
||||
import java.util.*
|
||||
|
||||
interface Document {
|
||||
|
||||
@JvmDefault
|
||||
fun getType() = "document"
|
||||
}
|
||||
|
||||
class TextDocument : Document {
|
||||
override fun getType() = "text"
|
||||
|
||||
fun transformList(list : List<Number>) : List<Number> {
|
||||
return list.filter { n -> n.toInt() > 1 }
|
||||
}
|
||||
|
||||
fun transformListInverseWildcards(list : List<@JvmSuppressWildcards Number>) : List<@JvmWildcard Number> {
|
||||
return list.filter { n -> n.toInt() > 1 }
|
||||
}
|
||||
|
||||
var list : List<@JvmWildcard Any> = ArrayList()
|
||||
}
|
||||
|
||||
class XmlDocument(d : Document) : Document by d
|
||||
|
||||
fun main() {
|
||||
val myDocument = TextDocument()
|
||||
val myTextDocument = XmlDocument(myDocument)
|
||||
println("${myDocument.getType()} ${myTextDocument.getType()}")
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.baeldung.jvmannotations;
|
||||
|
||||
public class HtmlDocument implements Document {
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "HTML";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
@file:JvmName("MessageHelper")
|
||||
@file:JvmMultifileClass //used
|
||||
package com.baeldung.jvmannotations
|
||||
|
||||
import java.util.*
|
||||
|
||||
@JvmName("getMyUsername")
|
||||
fun getMyName() : String {
|
||||
return "myUserId"
|
||||
}
|
||||
|
||||
object MessageBroker {
|
||||
@JvmStatic
|
||||
var totalMessagesSent = 0
|
||||
|
||||
const val maxMessageLength = 0
|
||||
|
||||
@JvmStatic
|
||||
fun clearAllMessages() {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
@Throws(Exception::class)
|
||||
fun findMessages(sender : String, type : String = "text", maxResults : Int = 10) : List<Message> {
|
||||
if(sender.isEmpty()) {
|
||||
throw Exception()
|
||||
}
|
||||
return ArrayList()
|
||||
}
|
||||
}
|
||||
|
||||
class Message {
|
||||
|
||||
// this would cause a compilation error since sender is immutable
|
||||
// @set:JvmName("setSender")
|
||||
val sender = "myself"
|
||||
|
||||
// this works as name is overridden
|
||||
@JvmName("getSenderName")
|
||||
fun getSender() : String = "from:$sender"
|
||||
|
||||
@get:JvmName("getReceiverName")
|
||||
@set:JvmName("setReceiverName")
|
||||
var receiver : String = ""
|
||||
|
||||
@get:JvmName("getContent")
|
||||
@set:JvmName("setContent")
|
||||
var text = ""
|
||||
|
||||
// generates a warning
|
||||
@get:JvmName("getId")
|
||||
private val id = 0
|
||||
|
||||
@get:JvmName("hasAttachment")
|
||||
var hasAttachment = true
|
||||
|
||||
var isEncrypted = true
|
||||
|
||||
fun setReceivers(receiverNames : List<String>) {
|
||||
}
|
||||
|
||||
@JvmName("setReceiverIds")
|
||||
fun setReceivers(receiverNames : List<Int>) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("MessageHelper") //applies to all top level functions / variables / constants
|
||||
package com.baeldung.jvmannotations
|
||||
|
||||
fun convert(message: Message) {
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user