Cannot Find Symbol Error

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 742 Views - Last Post: 27 May 2011 - 11:14 AM Rate Topic: -----

#1 KaleXp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-May 11

Cannot Find Symbol Error

Posted 27 May 2011 - 07:54 AM

import java.util.Random;
public class Lin 
{private int data[];
 private Random generator = new Random();
 public  Lin(int size)
 { 
  data=new int[size];
 for (int i = 0; i<size; i++)
  data[i]=generator.nextInt(90);
   }
 public int SearchLinear(int searchKey)
 { int index;
 for (index = 0; index<data.length; index++);
  if(data[index]==searchKey)
   return index;
 return -1;
    }
  }   



// then when I Call that Class in Another class As following TestApplication It tells me (Symbol cannot be find) and gives me Error!!
 
import java.util.Scanner;
public class TestApplication
{
 
 public static void main (String[] args) 
{// My problem is in here it Cannot find Symbol Lin which is The class name of privouse class..!! 
 Lin Arr = new Lin();
System.out.print(Arr);
Scanner input = new Scanner(System.in);
int searchint;
int Position;
System.out.println ("please enter an integer to search or -1 to exit");
 searchint=input.nextInt();
   while (searchint!=-1)
   {
    Position=Arr.SearchLinear(searchint);
   if (Position==-1)
   System.out.println ("the Integer You were looking for wasnot find");
   else
   System.out.println ("the intger You were looking is in index "+Position);
   }
}
}


This post has been edited by macosxnerd101: 27 May 2011 - 10:18 AM
Reason for edit:: Title renamed to be more descriptive.


Is This A Good Question/Topic? 0
  • +

Replies To: Cannot Find Symbol Error

#2 cornetto456  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 438
  • Joined: 03-January 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 08:08 AM

import java.util.Random;
public class Lin extends TestApplication
{private int data[];
 private Random generator = new Random();
 public  Lin(int size)
 { 
  data=new int[size];
 for (int i = 0; i<size; i++)
  data[i]=generator.nextInt(90);
   }
 public int SearchLinear(int searchKey)
 { int index;
 for (index = 0; index<data.length; index++);
  if(data[index]==searchKey)
   return index;
 return -1;
    }
  }   



?


Hope this works :)


Just add the extend to you 'Lin' :)
Was This Post Helpful? -1
  • +
  • -

#3 KaleXp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-May 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 08:21 AM

emmm First appriciate Your answer But No,, I tried Your Solution and It Didnot resolved My problem My teacher said It's Becouse Of Path of Your Java File ..! but I don't hve Idea what He Talked About..! :( :( Iam about LosIng MY patience Right Now ..!
Was This Post Helpful? 0
  • +
  • -

#4 cornetto456  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 438
  • Joined: 03-January 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 08:24 AM

Try this : Tutorial for object instance of another class in java.
Was This Post Helpful? 0
  • +
  • -

#5 KaleXp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-May 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 08:27 AM

Thanks alot Lemme Try This One Too..!
Was This Post Helpful? 0
  • +
  • -

#6 cornetto456  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 438
  • Joined: 03-January 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 08:43 AM

Does it works? :)
Was This Post Helpful? 0
  • +
  • -

#7 KaleXp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-May 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 08:53 AM

No ,, Really :(!!! Do You knw how To call a Static Method in Non Static method ?
Was This Post Helpful? 0
  • +
  • -

#8 cornetto456  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 438
  • Joined: 03-January 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 09:01 AM

Edit: Wrong information :S

This post has been edited by cornetto456: 27 May 2011 - 09:14 AM

Was This Post Helpful? 0
  • +
  • -

#9 cornetto456  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 438
  • Joined: 03-January 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 09:08 AM

You also can do MyClass.myStaticMethod();
Was This Post Helpful? 0
  • +
  • -

#10 KaleXp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-May 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 09:45 AM

using that Code in where???
Was This Post Helpful? 0
  • +
  • -

#11 cornetto456  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 438
  • Joined: 03-January 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 09:46 AM

TestAplication :)
Was This Post Helpful? 0
  • +
  • -

#12 KaleXp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-May 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 09:47 AM

Ok...:}
Was This Post Helpful? 0
  • +
  • -

#13 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10781
  • View blog
  • Posts: 40,153
  • Joined: 27-December 08

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 10:23 AM

First, please properly indent your code so you and others can better read it. Are both classes located in the same directory? If you are compiling from the command line, you have to compile Lin.java before TestApplication.java.

@cornetto456: I would stay away from inheritance here. There is no clear is-a relationship with a parent and child class (ie., a Student class extending a Person class).
Was This Post Helpful? 0
  • +
  • -

#14 KaleXp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-May 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 10:44 AM

emmmm Same Directory ?? i remmber My Teacher at Univ told same But I couldnt get him !What Dose that suppose To mean !! could You tell How I knw if they are In the same Directory Or no .. !
thanks..!
Kale.J
Was This Post Helpful? 0
  • +
  • -

#15 cornetto456  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 438
  • Joined: 03-January 11

Re: Cannot Find Symbol Error

Posted 27 May 2011 - 10:54 AM

That for example your got a directory 'test' and that there your 'Lin' And 'TestApplication' Class

that's what macosxnerd101 means :)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2