We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Java
  3. Data Structures
  4. Java 1D Array
  5. Discussions

Java 1D Array

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • tejgadu339
    12 months ago+ 2 comments

    import java.util.*;

    public class Solution1{

    public static void main(String args[]){
    
        Scanner scan=new Scanner(System.in);
    
        int size=scan.nextInt();
    
        int a[]=new int[size];
    
        for(int i=0;i<size;i++){
    
            a[i]=scan.nextInt();
        }
        for(int i=0;i<a.length;i++){
    
            if(i==a.length-1){
    
                System.out.print(a[i]+".");
            }
            else{
                System.out.print(a[i]+",");
            }
        }
        scan.close();
    }
    

    }

    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy