Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Compile time error(java) (https://www.askmehelpdesk.com/showthread.php?t=829652)

  • Jan 2, 2017, 11:16 AM
    rahulv_97
    Compile time error(java)
    error description:
    compiletime error in line 69
    code:

    import java.util.Scanner;
    public class sorte
    { void sort(int n,int[] a)
    { int temp;
    for(int I=0;i<n;i++)
    { for(int j=0;j<n-i-1;j++)
    { if(a[j]>a[j+1])
    { temp=a[j+1];
    a[j+1]=a[j];
    a[j]=temp;
    }
    }
    }
    }
    void display(int x,int[] y)
    {
    for(int I=0;i<x;i++)
    {
    System.out.println(+y[i]);
    }
    }








    public class sort of
    { public static void main(String args[])
    {
    Scanner in=new Scanner(System.in);
    int[] a=new int[30];
    int[] b=new int[30];
    int[] d=new int[60];

    System.out.println("enter array size");
    int n=in.nextInt();
    System.out.println("enter the 1st array elements");
    for(int I=0;i<n;i++)
    {
    a[i]=in.nextInt();
    }
    sort(n,a);
    System.out.println("the sorted array is");
    display(n,a);
    System.out.println("enter array size");
    int c=in.nextInt();
    System.out.println("enter the 1st array elements");
    for(int I=0;i<c;i++)
    {
    b[i]=in.nextInt();
    }
    sort(c,b);
    System.out.println("the sorted array is");
    display(c,b);
    System.out.println("the merged array is:");
    int g;
    g=n+c;


    for(int I=0;i<n;i++)
    {
    d[i]=a[i];
    }
    for(int j=0;j<g-n-1;j++)
    {
    d[j]=b[j];
    }
    System.out.println("the sorted merged array is");
    sort(g,d);
    display(g,d);
    }}
  • Jan 3, 2017, 09:25 AM
    CravenMorhead
    Hard to say without knowing what is on line 69. (I don't have the will to try to count and know it is a fruitless endeavour regardless).

    The println in the display method looks a little funky though. I am more of a C++ guy then Java though.

  • All times are GMT -7. The time now is 07:31 AM.