Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling accessor from outside, but having noSuchMethodError

5 views
Skip to first unread message

Merciadri Luca

unread,
Mar 25, 2011, 6:48:43 PM3/25/11
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I've got a Tableau.java file which contains a Tableau class defined
like this:

==
public class Tableau
{
public int dimension;
public int generations;
public Cell[][] setOfCells;

public Tableau(int n, int s) // this is an accessor
{
setOfCells = new Cell[n][n];
dimension = n;
generations = s;
}

// some methods
}
==
I then need to instantiate a Tableau, in another file; I do it like this:
==
Tableau tableau = new Tableau(n, s); // this is l.41
// other things
==
The problem is that I get, after launching the bytecode,
==
Exception in thread "main" java.lang.NoSuchMethodError: Tableau.<init>(II)V
at userErrorHandling.checkArgsTypesValues(userErrorHandling.java:41)
[etc.]
==

Do you have any solution for this? I can't understand the error: I'm
calling correctly the accessor, which is also public.

Thanks.

- --
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- --

In the land of the blind, the one-eyed man is king.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2NG8sACgkQM0LLzLt8MhysQACeNlvswOZ4PoNT83LdQyyojGvd
MqkAnj/qkQGfeA9NN1C8jsU5o/ub6/U1
=n1Tc
-----END PGP SIGNATURE-----

Lew

unread,
Mar 25, 2011, 6:49:36 PM3/25/11
to
Merciadri Luca wrote:
> Do you have any solution for this? I can't understand the error: I'm
> calling correctly the accessor, which is also public.

http://sscce.org/

--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

Merciadri Luca

unread,
Mar 26, 2011, 2:21:46 AM3/26/11
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lew <no...@lewscanon.com> writes:

> Merciadri Luca wrote:
>> Do you have any solution for this? I can't understand the error: I'm
>> calling correctly the accessor, which is also public.
>
> http://sscce.org/

The question has to deal with a java problem in some univ. project. As a
result, I can't give too much code. I think that I've sent the most
important chunks. Rest of the code would normally not be useful here
(or, if so, please explain the error).

It pays to pay attention.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2NhfoACgkQM0LLzLt8MhzMwgCghrTzaGo/vG7LTBuBvMXAlGcp
GYEAnR2nj3OcplRUECh20vUzThwSNttI
=ycI7
-----END PGP SIGNATURE-----

Alex Mentis

unread,
Mar 26, 2011, 3:23:32 AM3/26/11
to
Merciadri Luca wrote:

> I've got a Tableau.java file which contains a Tableau class defined
> like this:
>
> ==
> public class Tableau
> {
> public int dimension;
> public int generations;
> public Cell[][] setOfCells;
>
> public Tableau(int n, int s) // this is an accessor
> {
> setOfCells = new Cell[n][n];
> dimension = n;
> generations = s;
> }
>
> // some methods
> }

"public Tableau(int n, int s)" is not an accessor, it's a constructor.
Accessors allow access to the private attributes of an object.

Since you've declared all of your class's attributes (dimension,
generations, setOfCells) public, you probably don't understand why you
need accessor methods.

The attributes of a class should typcially be protected from the users
of that class, and safe reading and writing of the class's attributes
should be handled by the class.

So, you would have instead:

public class Tableau
{
private int dimension;

// ...

public Tableau(int n, int s) // this is a constructor
{
// ...
}

public int getDimension() // this is an accessor
{
return dimension;
}

// other methods...
}

The public cannot read or write dimension directly because it's
private, but they can use the public method getDimension() which, as a
class method, has direct read access to dimension.

Assuming you don't create a public method that allows a user to change
the value of dimension, this ensures that the dimension of a Tableau
object will not change once it has been established with the
constructor.

> ==
> I then need to instantiate a Tableau, in another file; I do it like
> this: ==
> Tableau tableau = new Tableau(n, s); // this is l.41
> // other things
> ==
> The problem is that I get, after launching the bytecode,
> ==
> Exception in thread "main" java.lang.NoSuchMethodError:
> Tableau.<init>(II)V at
> userErrorHandling.checkArgsTypesValues(userErrorHandling.java:41)
> [etc.] ==

As for your actual question, I cannot reproduce your error with the
amount of information you've provided. My code's instantiation of
tableau works fine. The error must be somewhere in the code you've
omitted from the post.

Merciadri Luca

unread,
Mar 26, 2011, 5:27:58 AM3/26/11
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Alex Mentis" <f...@invalid.invalid> writes:

You are right. This is a fundamental aspect of OO programming that I
neglected. I'm currently learning, so this is excusable.


>
> The public cannot read or write dimension directly because it's
> private, but they can use the public method getDimension() which, as a
> class method, has direct read access to dimension.
>
> Assuming you don't create a public method that allows a user to change
> the value of dimension, this ensures that the dimension of a Tableau
> object will not change once it has been established with the
> constructor.
>
>> ==
>> I then need to instantiate a Tableau, in another file; I do it like
>> this: ==
>> Tableau tableau = new Tableau(n, s); // this is l.41
>> // other things
>> ==
>> The problem is that I get, after launching the bytecode,
>> ==
>> Exception in thread "main" java.lang.NoSuchMethodError:
>> Tableau.<init>(II)V at
>> userErrorHandling.checkArgsTypesValues(userErrorHandling.java:41)
>> [etc.] ==
>
> As for your actual question, I cannot reproduce your error with the
> amount of information you've provided. My code's instantiation of
> tableau works fine. The error must be somewhere in the code you've
> omitted from the post.

Okay. For evident reasons, I can't give a more detailed example as we
are many working on the subject and that other students might see my
code and thus use it. As a result, you might consider this thread as
closed. What does the (II)V mean, in the error?

Thanks.
- --
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- --

It takes two to tango.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2NsZ0ACgkQM0LLzLt8MhzeKACfYaVeoHTU3iHjpcU/GiTLs5S+
Ll4AoI8ijUI/yleyeiGwZYEwunNTMrnu
=aQ7S
-----END PGP SIGNATURE-----

Alex Mentis

unread,
Mar 26, 2011, 6:15:58 AM3/26/11
to
Merciadri Luca wrote:

> >> Exception in thread "main" java.lang.NoSuchMethodError:
> >> Tableau.<init>(II)V at
> >> userErrorHandling.checkArgsTypesValues(userErrorHandling.java:41)
> >> [etc.] ==
> >
> > As for your actual question, I cannot reproduce your error with the
> > amount of information you've provided. My code's instantiation of
> > tableau works fine. The error must be somewhere in the code you've
> > omitted from the post.
> Okay. For evident reasons, I can't give a more detailed example as we
> are many working on the subject and that other students might see my
> code and thus use it. As a result, you might consider this thread as
> closed. What does the (II)V mean, in the error?

I think that means the signature of the constructor it's looking for
takes two integers and "returns" void. NoSuchMethodError means that
your program can't find a constructor with a signature that matches the
call.

Usually this is caught at compile time. NoSuchMethodError "can only
happen at run time if the definition of a class has incompatibly
changed." You're could be using a different run time class than the
class you use at compile time due to a bad classpath setting.

Are your classes all in the same package, or are they in different
packages? Try rebuilding your entire project to ensure that all
packages are compiled in their current versions.

John B. Matthews

unread,
Mar 26, 2011, 7:02:26 AM3/26/11
to
In article <87d3lew...@merciadriluca-station.MERCIADRILUCA>,
Merciadri Luca <Luca.Me...@student.ulg.ac.be> wrote:

> > http://sscce.org/
> The question has to deal with a java problem in some univ. project.
> As a result, I can't give too much code. I think that I've sent the
> most important chunks. Rest of the code would normally not be useful
> here (or, if so, please explain the error).

I applaud your diligence, but you may be overlooking an essential
benefit of the sscce: by preparing a _short_ yet _complete_ example, you
automatically avoid exposing "too much code." Moreover, if the shorter
version eliminate the problem, you're more likely to have isolated "the
most important chunks."

--
[Please trim signatures.]

Lew

unread,
Mar 26, 2011, 8:33:13 AM3/26/11
to
On 03/26/2011 07:02 AM, John B. Matthews wrote:
> In article<87d3lew...@merciadriluca-station.MERCIADRILUCA>,
> Merciadri Luca<Luca.Me...@student.ulg.ac.be> wrote:
>
>>> http://sscce.org/
>> The question has to deal with a java [sic] problem in some univ. project.

>> As a result, I can't give too much code. I think that I've sent the
>> most important chunks. Rest of the code would normally not be useful

No, you haven't.

>> here (or, if so, please explain the error).

Did you even bother to read the link?

How can we explain the error without the information necessary?

> I applaud your diligence, but you may be overlooking an essential
> benefit of the sscce: by preparing a _short_ yet _complete_ example, you
> automatically avoid exposing "too much code." Moreover, if the shorter
> version eliminate the problem, you're more likely to have isolated "the
> most important chunks."

Plus, no one can help very much with the paucity of information given so far.

You said, Merciadri,


>> I then need to instantiate a Tableau, in another file; I do it like this:

"Another file" doesn't even make sense - Java as a language has compilation
units, you might want to say "classes" in this case, not "another file". As a
result I have no idea what you mean by that sentence. We need CODE to
understand what you have been unable to explain in natural language.

> Exception in thread "main" java.lang.NoSuchMethodError: Tableau.<init>(II)V
> at userErrorHandling.checkArgsTypesValues(userErrorHandling.java:41)
> [etc.]

Now just how in bloody blazes are we supposed to know what "etc." refers to?

In what context did the constructor appear?

What is the code for 'Tableau'? On the face of it you called a constructor
that does not exist in the class, but since we don't see the class, who can
tell? You're not telling.

>> Do you have any solution for this? I can't understand the error:

Yea, well, you didn't give enough data for anyone else to understand it
either. Even though you were told what to tell us, you refused. Refused!

>> I'm calling correctly the accessor, which is also public.

No, you're not, guaranteed. I can say that with utter certainty because - oh,
wait, I haven't seen any code at all, much less this mysterious accessor.

*What* accessor? You haven't shown any accessor.

Please _actually read_ http://sscce.org/ and follow its advice!

You demand help from strangers who act out of generosity and interest, but
give us nothing with which to help you. Is that smart? That is not in your
own interest. Be smart.

Why would anyone give you more advice anyway, since you've already shown
yourself unwilling to follow it?

Lew

unread,
Mar 26, 2011, 8:38:03 AM3/26/11
to
Merciadri Luca wrote:
> Okay. For evident reasons, I can't give a more detailed example as we
> are many working on the subject and that other students might see my
> code and thus use it. As a result, you might consider this thread as
> closed. What does the (II)V mean, in the error?

In other words, Mr. Cheater, you want us to do your homework for you and deny
all your classmates the benefit of your cheating.

And you won't even give us enough information to help you cheat, Mr. Cheater!

Simply amazing.

What school do you attend, and who's your professor?

Joshua Cranmer

unread,
Mar 26, 2011, 12:10:55 PM3/26/11
to
On 03/26/2011 02:21 AM, Merciadri Luca wrote:
> The question has to deal with a java problem in some univ. project. As a
> result, I can't give too much code. I think that I've sent the most
> important chunks. Rest of the code would normally not be useful here
> (or, if so, please explain the error).

Having answered questions in here for... years, I can honestly say that
where you think the problem lies is not where the problem actually lies.

In general, if you see an "Error" thrown as opposed to an "Exception",
it refers to the fact that the VM more or less "unexpectedly" failed. In
this case, it means that it cannot find the method in question in the
bytecode when it runs. Since the code was compiled, it knew about that
method at compile time, which means the code it saw at compile time is
not the same code it is seeing at runtime--in other words, it is a fault
of your build process, and not of your code.

So, ironically, giving us more code probably wouldn't help, unless you
actually go and muck around with dynamic reflective features in your code...

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth

Merciadri Luca

unread,
Mar 26, 2011, 4:03:00 PM3/26/11
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lew <no...@lewscanon.com> writes:

> Merciadri Luca wrote:
>> Okay. For evident reasons, I can't give a more detailed example as we
>> are many working on the subject and that other students might see my
>> code and thus use it. As a result, you might consider this thread as
>> closed. What does the (II)V mean, in the error?
>
> In other words, Mr. Cheater, you want us to do your homework for you
> and deny all your classmates the benefit of your cheating.
>
> And you won't even give us enough information to help you cheat, Mr. Cheater!
>
> Simply amazing.
>
> What school do you attend, and who's your professor?

Completely unappropriate, stupid and incorrect remark. You might ask
questions about many things without wanting people to make your
homework. If I wanted to cheat, think about it, I would not cheat
publicly. Just think. And furthermore I never cheat, especially in a
project that's there to prepare us for the exam. Silly remark.

Closed thread, I found the solution.

It's the early bird that gets the worm.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2ORnQACgkQM0LLzLt8MhzyYQCglyqCExfB6vIvCTMpLHL6+qPH
iEEAn2yD2PMrIPyfls9Tu7XsEGoYvb9o
=UvwQ
-----END PGP SIGNATURE-----

Lew

unread,
Mar 26, 2011, 4:47:45 PM3/26/11
to
Merciadri Luca wrote:

> Lew writes:
>> Merciadri Luca wrote:
>>> Okay. For evident reasons, I can't give a more detailed example as we
>>> are many working on the subject and that other students might see my
>>> code and thus use it. As a result, you might consider this thread as
>>> closed. What does the (II)V mean, in the error?
>>
>> In other words, Mr. Cheater, you want us to do your homework for you
>> and deny all your classmates the benefit of your cheating.
>>
>> And you won't even give us enough information to help you cheat, Mr. Cheater!
>>
>> Simply amazing.
>>
>> What school do you attend, and who's your professor?

> Completely unappropriate, stupid and incorrect remark. You might ask
> questions about many things without wanting people to make your

Yes, but would you hide your code, incomplete and buggy as it was then, and
refuse to participate in the conversation and otherwise reject every piece of
advice for which you asked if you weren't up to something nefarious?

What's inappropriate is your expectation that everyone will dance to your tune
and help you when you won't even describe your issues, and your strange
paranoid protectiveness of any feedback for which people here have asked.
That's what's inappropriate.

> homework. If I wanted to cheat, think about it, I would not cheat
> publicly. Just think. And furthermore I never cheat, especially in a
> project that's there to prepare us for the exam. Silly remark.
>
> Closed thread, I found the solution.

Well, bully for you! Et qui vous avez fait le Dieu, hein?

Care to share the answer to help others, or are you just a taker who
contributes nothing back?

That would be inappropriate.

Merciadri Luca

unread,
Mar 26, 2011, 5:43:19 PM3/26/11
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lew <no...@lewscanon.com> writes:

> Yes, but would you hide your code, incomplete and buggy as it was
> then, and refuse to participate in the conversation and otherwise
> reject every piece of advice for which you asked if you weren't up to
> something nefarious?
>
> What's inappropriate is your expectation that everyone will dance to
> your tune and help you when you won't even describe your issues, and
> your strange paranoid protectiveness of any feedback for which people
> here have asked. That's what's inappropriate.

What you don't understand is that if I hide my code, it is for
judicious reasons. If I had the possibility to show everything, in the
ideal world, I would. When dealing with other programming languages, I
always give what is commonly referred to as MWE (Minimum Working
Example; well, that might be predominantly called so for LaTeX, but
the idea is the same for any other language and you know it), but,
here, I can't give too much info, because they are directly rendered
as public info.

>> homework. If I wanted to cheat, think about it, I would not cheat
>> publicly. Just think. And furthermore I never cheat, especially in a
>> project that's there to prepare us for the exam. Silly remark.
>>
>> Closed thread, I found the solution.
>
> Well, bully for you! Et qui vous avez fait le Dieu, hein?
>
> Care to share the answer to help others, or are you just a taker who
> contributes nothing back?

Well, you don't know me personally, but I don't specially have some
kind of reluctance to help others. I like helping others, and I would
even explain some portions of my code (without showing it, just giving
the basic idea) to other students if they were really needing it
(there is nothing outrageous in this).

However, be realistic: if you share some big code chunks and that some
student who's taking the course google some keywords that make your
code chunks appear, he will obviously copy them.

I wouldn't specially dislike the fact that a student might copy some
chunks of my code (because, after all, he won't have learnt that much;
that's his problem), but the problem is that as the two sent projects
(mine and the cheater's one) would thus contain an important
percentage of same code, both would lead to a zero because you know
that plagiarism is forbidden, and generally a bad thing. That would be sad,
and I would be extremely angry.

This is one of the reasons why I don't share too much code here. Well,
there might be some cases where the interesting info is in the rest of
the code, but you need to understand that I can't give all a
class. Also think about the fact that it would be SO MUCH easier to
copy and paste a whole class than to copy selected chunks that are the
most relevant, at least to my eyes.

> That would be inappropriate.
You have the answer directly above. Note that I'm totally open to any
discussion, but only if it is constructive, and does not lead to
aggressive or potentially angering and sarcastic remarks.

All the best,

Laugh and the world laughs with you ... Cry and you will find no one
with tears.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2OXfcACgkQM0LLzLt8MhyeWACfcmJcANsKBgPVe9P7hXXQi/4N
LycAnjACzZGNdfvhyDPYu3kTYbcVLMu/
=P4Hw
-----END PGP SIGNATURE-----

Roedy Green

unread,
Mar 27, 2011, 2:26:43 AM3/27/11
to
On Fri, 25 Mar 2011 23:48:43 +0100, Merciadri Luca
<Luca.Me...@student.ulg.ac.be> wrote, quoted or indirectly quoted
someone who said :

> public Tableau(int n, int s) // this is an accessor
> {
> setOfCells = new Cell[n][n];
> dimension = n;
> generations = s;
> }

That is a "constructor", not an "accessor".

"accessors" is not a Java term. Accessor methods are called "getters"
and "setters". It sounds a bit babyish at first, but the terms are
short and easy to remember.

The usual convention goes like this:

/**
* constructor
* @param size number of rows and columns in the matrix
* @param generations number of generations to simulate
*/
public Tableau(int size, int generations)
{
this.cells = new Cell[size][size];
this.size= size;
this.generations = generations;
}

Note that Javadoc is considered almost as important at the executable
code. Its formal structure is one of the best and most important
features of Java. Comments are not noise the way they are in most
other languages. They are the secret of bug free and easy to modify
code. They force you to think clearly about your intentions.


--
Roedy Green Canadian Mind Products
http://mindprod.com
There are only two industries that refer to their customers as "users".
~ Edward Tufte

Roedy Green

unread,
Mar 27, 2011, 2:29:17 AM3/27/11
to
On Fri, 25 Mar 2011 23:48:43 +0100, Merciadri Luca
<Luca.Me...@student.ulg.ac.be> wrote, quoted or indirectly quoted
someone who said :

> public Cell[][] setOfCells;

It is extremely rare, except during debugging, to expose a array as
public. Instead you create getters and setters to manipulate it in
controlled ways making the array itself private. It also gives you a
place to insert debug code that you can't inadvertently bypass.

Roedy Green

unread,
Mar 27, 2011, 2:33:17 AM3/27/11
to
On Fri, 25 Mar 2011 23:48:43 +0100, Merciadri Luca
<Luca.Me...@student.ulg.ac.be> wrote, quoted or indirectly quoted
someone who said :

>Exception in thread "main" java.lang.NoSuchMethodError: Tableau.<init>(II)V
> at userErrorHandling.checkArgsTypesValues(userErrorHandling.java:41)
>[etc.]

That is not an error that newbies usually get. The problem is likely
how you are invoking the compiler and runtime and your classpaths
rather than anything in the code.

See
http://mindprod.com/jgloss/runerrormessages.html#NOSUCHMETHODERROR

You can find answers to most of your questions, such as the causes of
various compile time and run time errors most quickly in the Java
glossary. http://mindprod.com/jgloss/jgloss.html

Merciadri Luca

unread,
Mar 27, 2011, 4:01:21 AM3/27/11
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Merciadri Luca <Luca.Me...@student.ulg.ac.be> writes:

> Lew <no...@lewscanon.com> writes:
>
>> Merciadri Luca wrote:
>>> Do you have any solution for this? I can't understand the error: I'm
>>> calling correctly the accessor, which is also public.
>>
>> http://sscce.org/
> The question has to deal with a java problem in some univ. project. As a
> result, I can't give too much code. I think that I've sent the most
> important chunks. Rest of the code would normally not be useful here
> (or, if so, please explain the error).

Thanks for the different tricks.

Look on the sunny side of life!


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAk2O7tEACgkQM0LLzLt8MhxBVgCeIBxbU6scAEQ/fcDHClbNqHdN
lcgAnRwOvzRWkBwYizPCwZ79dqT9r5dL
=RM5u
-----END PGP SIGNATURE-----

Patricia Shanahan

unread,
Mar 27, 2011, 8:37:25 AM3/27/11
to
On 3/26/2011 2:43 PM, Merciadri Luca wrote:
...

> What you don't understand is that if I hide my code, it is for
> judicious reasons. If I had the possibility to show everything, in the
> ideal world, I would. When dealing with other programming languages, I
> always give what is commonly referred to as MWE (Minimum Working
> Example; well, that might be predominantly called so for LaTeX, but
> the idea is the same for any other language and you know it), but,
> here, I can't give too much info, because they are directly rendered
> as public info.
...

You need to read and apply http://sscce.org/

Stripping your code down to an SSCCE, which is really more specific
terminology for MWE, would have several major benefits:

1. Often, you will find the error yourself in the process.

It is very easy to fix on one aspect of some code, often the least
familiar aspect, and assume that any and all errors must relate to that.
As you strip away what you think is irrelevant, you may find removing
something else makes the error go away.

For example, you would have found your problem in the "Enum list" thread
when you removed the array structure and assigned the enum element to a
simple variable instead.

2. You would get your answers a lot quicker. It often takes a lot of
messages to find out enough about what is really going on in your
program to answer the question. There are many people in this newsgroup
who, given an SSCCE and its error messages, would be able to tell you
immediately what the messages really mean, and what sort of changes you
will need to make to fix them.

3. The SSCCE will generally not be useful for anything except answering
questions. You can even edit it to change identifiers to make it less
informative about the whole program.

Patricia

Alex Mentis

unread,
Mar 27, 2011, 9:42:13 AM3/27/11
to
Roedy Green wrote:

> "accessors" is not a Java term. Accessor methods are called "getters"
> and "setters". It sounds a bit babyish at first, but the terms are
> short and easy to remember.
>

It is not correct to say that "'accessors' is not a Java term," to wit:

Schildt, Herbert. /Java: A Beginner's Guide/, 3rd ed., McGraw
Hill/Osborne, 2005 uses the term "accessors".

Horstman, Cay. /Big Java/, 4th ed., John Wiley & Sons, Inc., 2010 uses
the terms "accessors" and "mutators."

Loy, Marc, et. al. /Java Swing/, 2nd ed., O'Reilly, 2002 uses the terms
"accessors" and "mutation methods."

Sun's (now Oracle's) own tutorial on Java calls them "accessors" in
Part 1, Lesson 2 "Essentials."
(http://java.sun.com/developer/onlineTraining/Programming/BasicJava1/prog.html)

Wojtek

unread,
Mar 28, 2011, 1:49:16 AM3/28/11
to
Merciadri Luca wrote :

> However, be realistic: if you share some big code chunks and that some
> student who's taking the course google some keywords that make your
> code chunks appear, he will obviously copy them.
>
> I wouldn't specially dislike the fact that a student might copy some
> chunks of my code (because, after all, he won't have learnt that much;
> that's his problem), but the problem is that as the two sent projects
> (mine and the cheater's one) would thus contain an important
> percentage of same code, both would lead to a zero because you know
> that plagiarism is forbidden, and generally a bad thing. That would be sad,
> and I would be extremely angry.

Are you teaching a Java programming class? Or a generic programming
class which just happens to use Java as the vehicle?

In either case I think you should spend a LOT more time using and
learning Java before you pass on your tentative Java knowledge to
others.

Beside you have an error:

public Tableau(int n, int s)

{
setOfCells = new Cell[n][n];
dimension = n;
generations = s;
}

Should this line be:
setOfCells = new Cell[n][s];

where the second dimension uses 's' rather than 'n'?

--
Wojtek :-)


Lew

unread,
Mar 28, 2011, 7:12:39 AM3/28/11
to
Wojtek wrote:
> Beside you have an error:
>
> public Tableau(int n, int s)
> {
> setOfCells = new Cell[n][n];
> dimension = n;
> generations = s;
> }
>
> Should this line be:
> setOfCells = new Cell[n][s];
>
> where the second dimension uses 's' rather than 'n'?

No. He's making a square array (n x n).

Well, actually he's making array of length n with elements also arrays of
length n. He's using that to emulate an n x n square array.

Wojtek

unread,
Mar 29, 2011, 12:28:21 AM3/29/11
to
Lew wrote :

> Wojtek wrote:
>> Beside you have an error:
>>
>> public Tableau(int n, int s)
>> {
>> setOfCells = new Cell[n][n];
>> dimension = n;
>> generations = s;
>> }
>>
>> Should this line be:
>> setOfCells = new Cell[n][s];
>>
>> where the second dimension uses 's' rather than 'n'?
>
> No. He's making a square array (n x n).
>
> Well, actually he's making array of length n with elements also arrays of
> length n. He's using that to emulate an n x n square array.

Or the intent could be n elements with arrays of s

But then lower down I see that he steps through the array in both
dimensions using the same limiting variable, so n x n it is...

--
Wojtek :-)


0 new messages