FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
swift-java/Samples/JavaSieve/Sources/JavaSieve/main.swift at main · swiftlang/swift-java · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
swiftlang
/
swift-java
Public
Notifications
You must be signed in to change notification settings
Fork
120
Star
1.2k
Code
Issues
130
Pull requests
8
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
swift-java
/
Samples
/
JavaSieve
/
Sources
/
JavaSieve
/
main.swift
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (27 loc) · 914 Bytes
Breadcrumbs
swift-java
/
Samples
/
JavaSieve
/
Sources
/
JavaSieve
/
main.swift
Copy path
File metadata and controls
31 lines (27 loc) · 914 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2024 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import
JavaMath
import
SwiftJava
let
jvm
=
try
JavaVirtualMachine
.
shared
(
)
// snippet.sieveUsage
do
{
let
sieveClass
=
try
JavaClass
<
SieveOfEratosthenes
>
(
environment
:
jvm
.
environment
(
)
)
for
prime
in
sieveClass
.
findPrimes
(
100
)
!
{
print
(
"
Found prime:
\(
prime
.
intValue
(
)
)
"
)
}
_
=
try
JavaClass
<
RoundingMode
>
(
)
.
HALF_UP // can import a Java enum value
}
catch
{
print
(
"
Failure:
\(
error
)
"
)
}
// snippet.end
Back
|
FazBrowse Home
|
New Git URL