Results 1 to 4 of 4
  1. #1
    Udaycampus is offline Member
    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Default this program compiles with no suntax errors but does not run,help !

    i did this code to insert a no into an array at a desired position while keeping other elements intact and also to delete an elemnt from the array....it compiles with no syntax errors but does not run ...help :( i am using blue j

    Java Code:
    import java.io.*;
    public class rearrange
    {
    int n,pos1,pos2,item;
    int a[]=new int[200];
    int k[]=new int[200];
    int c[]=new int[200];
    public void enter()throws IOException
    {
    InputStreamReader reader=new InputStreamReader(System.in);
    BufferedReader input=new BufferedReader(reader);
    System.out.println("enter size of array");
    n=Integer.parseInt(input.readLine());
    int i;
    System.out.println();
    for(i=0;i<n;i++)
    {
    a[i]=Integer.parseInt(input.readLine());
    k[i]=a[i];
    c[i]=a[i];
    System.out.print(a[i]+" ");
    }
    }
    public void insert(int m,int p)
    {
    System.out.println();
    int i,j,g,temp,imp;
    g=n+1;
    imp=k[p];
    for(i=0;i<g;i++){
    if(i>p || i==p)
    {
    temp=imp;
    imp=k[i+1];
    k[i+1]=temp;
    }
    k[p]=m;
    }
    }
    public void disp1()
    {
    int i;
    for(i=0;i<=n;i++){
    System.out.print(k[i]+" ");
    }
    }
    public void remove(int mo,int q)
    {
    System.out.println();
    int i,j;
    for(i=0;i<n-1;i++){
    if(i==q || i>q){
    c[i]=c[i+1];
    }
    }
    }
    public void disp2()
    {
    int i;
    for(i=0;i<(n-1);i++)
    {
    System.out.print(c[i]+" ");
    }
    }
    public static void main(String []args)throws IOException
    {
    InputStreamReader reader=new InputStreamReader(System.in);
    BufferedReader input=new BufferedReader(reader);
    rearrange obj=new rearrange();
    int pos1=Integer.parseInt(input.readLine());
    int pos2=Integer.parseInt(input.readLine());
    int item=Integer.parseInt(input.readLine());
    obj.enter();
    obj.insert(item,pos1);
    obj.disp1();
    obj.remove(item,pos2);
    obj.disp2();
    }
    }
    Last edited by Udaycampus; 12-07-2012 at 08:11 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: this program compiles with no suntax errors but does not run,help !

    Please go through Guide For New Members and BB Code List - Java Programming Forum and edit your post accordingly.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Udaycampus is offline Member
    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Default Re: this program compiles with no suntax errors but does not run,help !

    Quote Originally Posted by DarrylBurke View Post
    Please go through Guide For New Members and BB Code List - Java Programming Forum and edit your post accordingly.

    db
    I have edited it accordingly but could not remove help from title.....please solve the problem i am facing in running this code

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: this program compiles with no suntax errors but does not run,help !

    Do you always wrote your code all left-aligned, without indentation, so that it's near impossible to read? Maybe you need to go through Code Conventions for the Java Programming Language: Contents

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. program compiles but does not work
    By alara in forum New To Java
    Replies: 4
    Last Post: 11-27-2011, 09:47 PM
  2. BlueJ compiles with no errors...but doesn't run
    By NixasMuraki in forum New To Java
    Replies: 3
    Last Post: 06-01-2011, 07:35 PM
  3. compiles but I get errors, need help
    By jjth39347 in forum New To Java
    Replies: 3
    Last Post: 03-06-2011, 09:29 PM
  4. Replies: 6
    Last Post: 02-08-2011, 03:29 AM
  5. Errors driving me crazy! although compiles fine
    By irishsea2828 in forum New To Java
    Replies: 1
    Last Post: 04-08-2008, 04:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •