This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hi to all...iam very new in using Jbuilder i have a small question that if i have built two classes and i have defined a string in the first class that contains a user input file..then in the second class i need to calculate the length of that string(the user input file) so i said Line.lenght() but i had thr error: Error #: 300 : variable Line not found in class project_two.Calculate_Padding_bits at line 19, column 10 what i shall do ..by the way the two classes is on the same Package and even that i tried to make import for the first class in the second one...plz help me on this problem.... Mohammad
My guess is that you're not taking into account that you have two classes. The variable is only defined in your first class, not the second. Like this:
In Class2, x is not defined. So the compiler will question why you're using it. If you need to access an attribute in another class, there are two accepted ways: direct access, and accessor methods. Direct access seems to be frowned on, but for low security data, often modified data, or simple projects, I don't see it as a problem. This method is to make the attribute protected (accessible by subclasses), package, or public, and just access them through an object:
With Object Oriented programming, a new idea was created: accessor methods. The idea behind this is to limit all attributes to private, and write functions to view or modify the data:
This has become the most accepted way to deal with attributes, as you can limit a variable to read only, write-only, or read-write depending on the object itself. It also allows you to perform the modification at an appropriate time, to avoid crashes.
thanx a lot for this useful reply...i want to ask another small question that : if i have defined in my code : static int length; then i need to convert and represent this integer into 64-bit big indean what shall i do in java ...can i find any function to do this??
Originally posted by Mohammad Ahmad: thanx a lot for this useful reply...i want to ask another small question that : if i have defined in my code : static int length; then i need to convert and represent this integer into 64-bit big indean what shall i do in java ...can i find any function to do this??