output with comma java

Solutions on MaxInterview for output with comma java by the best coders in the world

showing results for - "output with comma java"
Natalia
12 Aug 2018
1public class Primes {
2
3 public static void main(String[] args) {
4
5    StringJoiner joiner = new StringJoiner(",");
6
7    Scanner sc = new Scanner(System.in);
8    int start = sc.nextInt();
9    int end = sc.nextInt();
10
11    for (int i =start; i <= end; i++) {
12
13        if (isPrime(i)) {
14            joiner.add(Integer.toString(i));
15        }
16
17    }
18
19    System.out.println(joiner.toString());
20}