Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
IT Security ToolsHashcatRosetta(02.10.2026 um 19:23 Uhr)
•
IT Security NachrichtenThe legal questions raised by agentic AI hacks(02.10.2026 um 19:47 Uhr)
••
Sicherheitslücken (CVE)FortiMail zero-day exploited in attacks as CISA urges immediate patching(02.10.2026 um 19:28 Uhr)
•
IT Security NachrichtenNew infosec products of the week: October 2, 2026(02.10.2026 um 06:00 Uhr)
•
IT Security NachrichtenAI agents keep access to company data after their work is done(02.10.2026 um 06:30 Uhr)
••
Malware / Trojaner / VirenAndroid 17 makes it harder for spyware to cover its tracks(02.10.2026 um 07:30 Uhr)
•
IT Security NachrichtenCriminal recruiters want people on your payroll(02.10.2026 um 08:00 Uhr)
•
Sicherheitslücken (CVE)Critical FortiMail zero-day exploited in the wild (CVE-2026-104286)(02.10.2026 um 10:50 Uhr)
•
IT Security ToolsHashcatRosetta(02.10.2026 um 19:23 Uhr)
•
IT Security NachrichtenThe legal questions raised by agentic AI hacks(02.10.2026 um 19:47 Uhr)
••
Sicherheitslücken (CVE)FortiMail zero-day exploited in attacks as CISA urges immediate patching(02.10.2026 um 19:28 Uhr)
•
IT Security NachrichtenNew infosec products of the week: October 2, 2026(02.10.2026 um 06:00 Uhr)
•
IT Security NachrichtenAI agents keep access to company data after their work is done(02.10.2026 um 06:30 Uhr)
••
Malware / Trojaner / VirenAndroid 17 makes it harder for spyware to cover its tracks(02.10.2026 um 07:30 Uhr)
•
IT Security NachrichtenCriminal recruiters want people on your payroll(02.10.2026 um 08:00 Uhr)
•
Sicherheitslücken (CVE)Critical FortiMail zero-day exploited in the wild (CVE-2026-104286)(02.10.2026 um 10:50 Uhr)
•
Intelligence View
⚡ tsecurity.de Intelligence

Groovy Collection - Set, List, Map, Range

Groovy Collection Groovy는 다양한 컬렉션 타입을 지원하며, Java보다 간결한 문법을 제공합니다. Set // Creating a Set def Set1 = [1, 2, 1, 4, 5, 9] as Set Set Set2 = new HashSet(['a', 'b', '…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!




Groovy Collection



Groovy는 다양한 컬렉션 타입을 지원하며, Java보다 간결한 문법을 제공합니다.






Set






// Creating a Set
def Set1 = [1, 2, 1, 4, 5, 9] as Set
Set Set2 = new HashSet(['a', 'b', 'c', 'd'])

// Modifying a Set
Set2.add(1)
Set2.add(9)
Set2.addAll([4, 5]) // Set2: [1, d, 4, b, 5, c, a, 9]
Set2.remove(1)
Set2.removeAll([4, 5]) // Set2: [d, b, c, a, 9]

// Union of Set
Set Union = Set1 + Set2 // Union: [1, 2, 4, 5, 9, d, b, c, a]

// Intersection of Set
Set intersection = Set1.intersect(Set2) // Intersection: [9]

// Complement of Set
Set Complement = Union.minus(Set1) // Complement: [d, b, c, a]












List






// Creating a List
def list1 = ['a', 'b', 'c', 'd']
def list2 = [3, 2, 1, 4, 5] as List

// Reading a List
println list1[1] // Output: b
println list2.get(4) // Output: 5
println list1.get(5) // Throws IndexOutOfBoundsException









유틸리티 메서드






// Sort a List
println list2.sort() // Output: [1, 2, 3, 4, 5]

// Reverse a list
println list1.reverse() // Output: [d, c, b, a]

// Finding elements
println ("Max:" + list2.max() + ":Last:" + list1.last())
// Output: Max:5:Last:d

println list2.find({ it % 2 == 0 }) // Output: 2
println list2.findAll({ it % 2 == 0 }) // Output: [2, 4]












Map






// 두 표기법은 동일
Map m1 = [name: "Groovy"]
Map m1 = ["name": "Groovy"]

// 변수를 키로 사용
String s1 = "name"
Map m1 = [(s1): "Groovy"]

def m2 = [id: 1, title: "Mastering Groovy"] as Map









Map 접근






m2.get("id")
m2["id"]









Map 검증






ageMap.any { entry -> entry.value > 25 }   // 하나라도 만족하면 true
ageMap.every { entry -> entry.value > 18 } // 모두 만족하면 true












Range






def range1 = 1..10
Range range2 = 'a'..'e'

// Iteration
range1.each { println it }

// Validation
range1.any { it > 5 }
range1.every { it > 0 }

// Step
List l1 = range1.step(2) // Output: [1, 3, 5, 7, 9]

// Properties
range1.getFrom() // Output: 1
range1.getTo() // Output: 10
range1.isReverse() // Output: false (값이 증가하는지 감소하는지 확인)









Originally published at https://dss99911.github.io

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Groovy Collection - Set, List, Map, Range

Thematisch verwandte Begriffe: Groovy, Collection, List, Range · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag