简体   繁体   中英

Java Cannot find Symbol in Another Class

I'm trying to create a simple math function that makes use of a few other classes. One class is named iRect and has a few int values referring to the coordinates of two corners of a rectangle, and another class called iPoint , which only has two integer values for x and y coordinates. There is a third class that contains the main method, and all I'm trying to do is assign some values from instances of these classes to values within the main class.

For instance, when I use the code iPoint bFt = new iPoint() to initialize a new iPoint, the compiler has no problems with this. However, when I try to assign the x value from another iPoint that was successfully initialized to bFt , simply by typing out bFt.x = iRectInstance.leftPoint1X; Both of these items are of the same type, but my compiler is telling me that it can't find the variable leftPoint1X in the iRect class, even though when I go over there and check, the field int leftPoint1X is right there after the opening bracket, and iRect itself is in the same folder as the main file. Does anyone know what the cause of this could be?.

Make sure the accessibility of the fields you are trying to evaluate (from another class) are public.

Java Access Modifiers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM