Results 1 to 14 of 14
  1. #1
    florida is offline Member
    Join Date
    Mar 2013
    Posts
    13
    Rep Power
    0

    Post to fix the error

    Java Code:
    import java.io.DataInputStream;
    class temperature
    {
       int row;
       int col;
       int highest(int a[][],int row ,int col)
          { 
              int array3[] = new int[3];
              int b = 0,c,d;
                 for(int i=0;i<row;i++)
    	  {
    	     for(int j=0;j<col;j++)
                             {
    	            if(b<a[i][j])
                                 {
    	                  array3[0] =a[i][j];
                                      array3[1] = i;
    		  array3[2] = j;
    	             }
                             }
                        }
                return (array3[]);
          }         
     int lowest(int a[][],int row ,int col,int highest)
         { 
            int array4[] = new int[3];
            int b=highest;
            for(int i=0;i<row;i++)
               {
                  for(int j=0;j<col;j++)
                       {
                             if(b>a[i][j])
                             {
    	             array4[0] =a[i][j];
                                 array4[1] = i;
    	             array4[2] = j;
                             }
                        }
                }
              return (array4[]);
        }
    public static void main(String args[])
      {
         DataInputStream in = new DataInputStream(System.in);
         int array1[] = new int[3];
         int array2[] = new int[3]; 
      try
         {
             System.out.println("enter the num of rows");
             int row = Integer.parseInt(in.readLine());
             System.out.println("enter the num of rows");
             int col = Integer.parseInt(in.readLine());
             int a[][] = new int[row][col];
             for(int i =0;i<row;i++)
               {
                  for(int j=0;j<col;j++)
                      {
                          System.out.println("Enter the value :");
                         a[i][j]=Integer.parseInt(in.readLine());
    	   }
                }
             for(int k=0;k<row;k++)
                {
                  for(int l=0;l<col;l++)
    	 {
                        System.out.print(a[k][l]+" ");
    	  }
                }
            array1[3] = highest(a,row,col);
            array2[3] = highest(a,row,col,array1[0]);
            System.out.println("The highest temp :"+array1[0]);
            System.out.println("The day : "+array1[1]);
            System.out.println("The country : "+array2[2]);
            System.out.println("The highest temp :"+array2[0]);
            System.out.println("The day : "+array2[1]);
            System.out.println("The country : "+array2[2]);
        }
         catch(Exception e)
         {
            e.printStackTrace();
         }
    }       
    }


    D:\bharathi\Java2\jdk1.6.0_33\bin>javac temperature.java
    temperature.java:22: illegal start of expression
    return (array3[]);
    ^
    temperature.java:40: illegal start of expression
    return (array4[]);
    ^
    Last edited by florida; 03-07-2013 at 04:39 AM.

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: to fix the error

    Oh, come on! Please format your code. Use the [code][/code] tag, make it readable. It is not help us, it is help you.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

    Default Re: to fix the error

    Please go through the Forum Rules, particularly the third paragraph. Also go through Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly. To edit the subject line, click 'Edit Post' and then 'Go Advanced'

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

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: to fix the error

    And while you're at it you also might want to ask a question.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    florida is offline Member
    Join Date
    Mar 2013
    Posts
    13
    Rep Power
    0

    Default Re: to fix the error

    i get rid of the error..........thank u guys

  6. #6
    Jamil37037 is offline Member
    Join Date
    Feb 2013
    Location
    Islamabad, Pakistan
    Posts
    25
    Rep Power
    0

    Default Re: to fix the error

    Have you tried it??? Show some effort in this.

  7. #7
    tamilarasi is offline Member
    Join Date
    Nov 2012
    Location
    India
    Posts
    70
    Rep Power
    0

    Default Re: to fix the error

    Quote Originally Posted by florida View Post
    D:\bharathi\Java2\jdk1.6.0_33\bin>javac temperature.java
    temperature.java:22: illegal start of expression
    return (array3[]);
    ^
    temperature.java:40: illegal start of expression
    return (array4[]);
    ^
    yes, Issue occurred those lines
    that's is
    Java Code:
    int highest(int a[][],int row ,int col)
    int lowest(int a[][],int row ,int col,int highest)
    because you created the method with integer return type.But you return integer array.
    So you modify the return type int into int[].
    Regards
    Android developer at Trinay Technology Solutions,http://www.trinaytech.com,5705750475

  8. #8
    florida is offline Member
    Join Date
    Mar 2013
    Posts
    13
    Rep Power
    0

    Default Re: to fix the error

    Thank u............ it has worked

  9. #9
    florida is offline Member
    Join Date
    Mar 2013
    Posts
    13
    Rep Power
    0

    Default Re: to fix the error

    Java Code:
    import java.io.DataInputStream;
    import java.util.ArrayList;
    class tempa
    {
      ArrayList<Integer> highest(int a[][],int row,int col)
          {  
              ArrayList<Integer> arraylist1=new ArrayList<Integer>();
              int b=a[0][0];
    	    for(int i=0;i<row;i++)
    	     {
    		for(int j=0;j<col;j++)
    		  {
    		    if(b<=a[i][j])
                          {
    			 arraylist1.add(a[i][j]);
    			 arraylist1.add(i);
    			 arraylist1.add(j);
    		       }
                        else
                           {
    			 arraylist1.add(a[i][j]);
    			 arraylist1.add(i);
    			 arraylist1.add(j);
    		       }
    		   }
    	      }
                return(arraylist1);
    	}         
    ArrayList<Integer> lowest(int a[][],int row,int col)
    	{ 
    	  ArrayList<Integer> arraylist2=new ArrayList<Integer>();
              int b=a[0][0];
              
    	    for(int i=0;i<row;i++)
    	     {
    		for(int j=0;j<col;j++)
    		  {
    		    if(b>a[i][j])
                          {
    			 arraylist2.add(a[i][j]);
    			 arraylist2.add(i);
    			 arraylist2.add(j);
    		       }
                        else
                           {
    			 arraylist2.add(a[i][j]);
    			 arraylist2.add(i);
    			 arraylist2.add(j);
    		       }
    		   }
    	      }
    	     return(arraylist2);
    	 }
    }
    class temperature
    {
    public static void main(String args[])
     {
      int row,col;
      tempa t1 = new tempa();
      ArrayList<Integer> arraylist3=new ArrayList<Integer>();
      ArrayList<Integer> arraylist4=new ArrayList<Integer>();
      DataInputStream in = new DataInputStream(System.in); 
      try
      {
      System.out.println("enter the num of rows and cols:");
      row = Integer.parseInt(in.readLine());
      col = Integer.parseInt(in.readLine());
      int a[][] = new int[row][col];
      System.out.println("enter the elements");
      for(int i =0;i<row;i++)
         {
            for(int j=0;j<col;j++)
              {
                 a[i][j]=Integer.parseInt(in.readLine());
    	   }
         }
       for(int i=0;i<row;i++)
          {
    	 for(int j=0;j<col;j++)
    	    {
                  System.out.print(a[i][j]+"\t");
                  
                }
              System.out.println();
          }
          arraylist3 = t1.highest(a,row,col);
          arraylist4 = t1.lowest(a,row,col);
          for(int k =0;k<arraylist3.size();)
              {
                 System.out.println("The highest temperature: "+arraylist3.get[k]);
                 k = k+1;
                 System.out.println("The day : "+arraylist3.get[k]);
    	     k = k+1;
                 System.out.println("The country code is : "+arraylist3.get[k]);
                 k = k+1;
               }
          for(int l =0;l<arraylist3.size();)
              {
                 System.out.println("The highest temperature: " +arraylist4.get[l]);
                 l = l+1;
                 System.out.println("The day : "+arraylist4.get[l]);
    	     l = l+1;
                 System.out.println("The country code is : "+arraylist4.get[l]);
                 l = l+1;
               }
      }
      catch(Exception e)
      {
        e.printStackTrace();
      }
    }  
    }
    temperature.java:91: cannot find symbol
    symbol : variable get
    location: class java.util.ArrayList<java.lang.Integer>
    System.out.println("The highest temperature: "+arraylist3.get[k]
    ^
    temperature.java:93: cannot find symbol
    symbol : variable get
    location: class java.util.ArrayList<java.lang.Integer>
    System.out.println("The day : "+arraylist3.get[k]);
    ^
    temperature.java:95: cannot find symbol
    symbol : variable get
    location: class java.util.ArrayList<java.lang.Integer>
    System.out.println("The country code is : "+arraylist3.get[k]);
    ^
    temperature.java:100: cannot find symbol
    symbol : variable get
    location: class java.util.ArrayList<java.lang.Integer>
    System.out.println("The highest temperature: " +arraylist4.get[l

    ^
    temperature.java:102: cannot find symbol
    symbol : variable get
    location: class java.util.ArrayList<java.lang.Integer>
    System.out.println("The day : "+arraylist4.get[l]);
    ^
    temperature.java:104: cannot find symbol
    symbol : variable get
    location: class java.util.ArrayList<java.lang.Integer>
    System.out.println("The country code is : "+arraylist4.get[l]);
    ^
    Note: temperature.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    6 errors


    help me...........
    Last edited by florida; 03-07-2013 at 03:39 PM.

  10. #10
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: to fix the error

    ArrayList i snot an array! List.get(index)
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  11. #11
    florida is offline Member
    Join Date
    Mar 2013
    Posts
    13
    Rep Power
    0

    Default Re: to fix the error

    thank u senior........... the error is cleared..................

  12. #12
    florida is offline Member
    Join Date
    Mar 2013
    Posts
    13
    Rep Power
    0

    Default Re: to fix the error

    Java Code:
    import java.io.DataInputStream;
    import java.util.ArrayList;
    class tempa
    {
      ArrayList<Integer> highest(int a[][],int row,int col)
          {  
              ArrayList<Integer> arraylist1=new ArrayList<Integer>();
              int c=0,d=0;
              arraylist1.add(a[0][0]);
              arraylist1.add(c);
              arraylist1.add(d);
    	    for(int i=0;i<row;i++)
    	     {
    		for(int j=0;j<col;j++)
    		  {
    		    if(arraylist1.get(0)<a[i][j])
                          {
    			 arraylist1.set(0,a[i][j]);
                             arraylist1.add(1,i);
    			 arraylist1.add(2,j);
    		      }
                        else (arraylist1.get(0)==a[i][j])
    		       {
    			 arraylist1.add(a[i][j]);
                             arraylist1.add(i);
    			 arraylist1.add(j);
    		       }
                     }                
    	      }
                return(arraylist1);
    	}         
      ArrayList<Integer> lowest(int a[][],int row,int col)
    	{ 
    	  ArrayList<Integer> arraylist2=new ArrayList<Integer>();
              arraylist2.add(a[0][0]);
              int c=0,d=0;
    	    for(int i=0;i<row;i++)
    	     {
    		for(int j=0;j<col;j++)
    		  {
    		    if(arraylist2.get(0)>a[i][j])
                          {
    			 arraylist2.set(0,a[i][j]);
    			 arraylist2.set(1,i);
    			 arraylist2.set(1,j);
    		       }
                        else((arraylist2.get(0))==equals(a[i][j]))
                           {
    			 arraylist2.add(a[0][0]);
    			 arraylist2.add(0);
    			 arraylist2.add(0);
    		       }
    		   }
    	      }
    	     return(arraylist2);
    	 }
    }
    class temperature
    {
    public static void main(String args[])
     {
      int row,col;
      tempa t1 = new tempa();
      ArrayList<Integer> arraylist3= new ArrayList<Integer>();
      ArrayList<Integer> arraylist4 = new ArrayList<Integer>();  
      DataInputStream in = new DataInputStream(System.in); 
      try
      {
      System.out.println("enter the num of rows and cols:");
      row = Integer.parseInt(in.readLine());
      col = Integer.parseInt(in.readLine());
      int a[][] = new int[row][col];
      System.out.println("enter the elements");
      for(int i =0;i<row;i++)
         {
            for(int j=0;j<col;j++)
              {
                 a[i][j]=Integer.parseInt(in.readLine());
    	   }
         }
       for(int i=0;i<row;i++)
          {
    	 for(int j=0;j<col;j++)
    	    {
                  System.out.print(a[i][j]+"\t");
                  
                }
              System.out.println();
          }
            arraylist3 = t1.highest(a,row,col);
            arraylist4 = t1.lowest(a,row,col);
            for(int i =0;i<arraylist3.size();)
              {
                 System.out.println("The highest temperature: "+arraylist3.get(i));
                 i = i+1;
                 System.out.println("The day : "+arraylist3.get(i));
    	     i = i+1;
                 System.out.println("The country code is : "+arraylist3.get(i));
                 i = i+1;
               }
          for(int l =0;l<arraylist4.size();)
              {
                 System.out.println("The lowest temperature: " +arraylist4.get(l));
                 l = l+1;
                 System.out.println("The day : "+arraylist4.get(l));
    	     l = l+1;
                 System.out.println("The country code is : "+arraylist4.get(l));
                 l = l+1;
               }
      }
      catch(Exception e)
      {
        e.printStackTrace();
      }
    }  
    }
    D:\bharathi\Java2\jdk1.6.0_33\bin>javac temperature.java
    temperature.java:22: not a statement
    else (arraylist1.get(0)==a[i][j])
    ^
    temperature.java:22: ';' expected
    else (arraylist1.get(0)==a[i][j])
    ^
    temperature.java:47: not a statement
    else((arraylist2.get(0))==(a[i][j]))
    ^
    temperature.java:47: ';' expected
    else((arraylist2.get(0))==(a[i][j]))
    ^

    help me..........

  13. #13
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    335
    Rep Power
    4

    Default Re: to fix the error


  14. #14
    tamilarasi is offline Member
    Join Date
    Nov 2012
    Location
    India
    Posts
    70
    Rep Power
    0

    Default Re: to fix the error

    you have the problem with else statement. Because you create else with parameter.

    But else is not get parameter.. you use if...else like below..

    Java Code:
    if(condition){
    }
    else if(condition){
    }
    else{
    }
    Regards
    Android developer at Trinay Technology Solutions,http://www.trinaytech.com,5705750475

Similar Threads

  1. Replies: 8
    Last Post: 11-22-2012, 07:16 AM
  2. Replies: 3
    Last Post: 05-08-2012, 05:26 PM
  3. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  4. Replies: 3
    Last Post: 01-23-2009, 08:53 AM

Posting Permissions

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