Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #19336 > unrolled thread
| Started by | K <kalezwe@gmail.com> |
|---|---|
| First post | 2012-10-14 17:44 -0700 |
| Last post | 2012-10-16 01:10 -0700 |
| Articles | 14 — 9 participants |
Back to article view | Back to comp.lang.java.programmer
boolean statement K <kalezwe@gmail.com> - 2012-10-14 17:44 -0700
Re: boolean statement glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-10-15 00:57 +0000
Re: boolean statement K <kalezwe@gmail.com> - 2012-10-14 18:25 -0700
Re: boolean statement Lew <lewbloch@gmail.com> - 2012-10-14 21:34 -0700
Re: boolean statement Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-10-15 06:54 +0000
Re: boolean statement Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-10-14 21:04 -0400
Re: boolean statement Gene Wirchenko <genew@ocis.net> - 2012-10-14 18:52 -0700
Re: boolean statement K <kalezwe@gmail.com> - 2012-10-14 19:55 -0700
Re: boolean statement Gene Wirchenko <genew@ocis.net> - 2012-10-14 20:10 -0700
Re: boolean statement Jeff Higgins <jeff@invalid.invalid> - 2012-10-15 08:20 -0400
Re: boolean statement Lew <lewbloch@gmail.com> - 2012-10-15 09:15 -0700
Re: boolean statement Roedy Green <see_website@mindprod.com.invalid> - 2012-10-14 22:41 -0700
Re: boolean statement Lew <lewbloch@gmail.com> - 2012-10-15 09:15 -0700
Re: boolean statement Robert Klemme <shortcutter@googlemail.com> - 2012-10-16 01:10 -0700
| From | K <kalezwe@gmail.com> |
|---|---|
| Date | 2012-10-14 17:44 -0700 |
| Subject | boolean statement |
| Message-ID | <81d2cb8c-292b-4efd-9a42-ac8ef0f86d0e@googlegroups.com> |
Why does my boolean statement have an error message next to it in eclipse?
public class boolean1 {
public static void main(String[] args) {
int gumballs;
int kids;
int gumballsPerKid;
boolean eachKidGetsTen;
gumballs = 140;
kids = 15;
gumballsPerKid = gumballs / kids;
System.out.print("True of False? ");
System.out.println("Each kid gets 10 gumballs");
eachKidGetsTen = gumballsPerKid >= 10;
System.out.println("eachKidGetsTen");
}
}
[toc] | [next] | [standalone]
| From | glen herrmannsfeldt <gah@ugcs.caltech.edu> |
|---|---|
| Date | 2012-10-15 00:57 +0000 |
| Message-ID | <k5fn16$gee$1@speranza.aioe.org> |
| In reply to | #19336 |
K <kalezwe@gmail.com> wrote:
> Why does my boolean statement have an error message next to it in eclipse?
It should be a warning, not an error, but you never use the value
of the variable. Eclipse nicely tells you that you might have
forgotten something.
-- glen
> public class boolean1 {
> public static void main(String[] args) {
> int gumballs;
> int kids;
> int gumballsPerKid;
> boolean eachKidGetsTen;
>
> gumballs = 140;
> kids = 15;
> gumballsPerKid = gumballs / kids;
>
> System.out.print("True of False? ");
> System.out.println("Each kid gets 10 gumballs");
> eachKidGetsTen = gumballsPerKid >= 10;
> System.out.println("eachKidGetsTen");
> }
[toc] | [prev] | [next] | [standalone]
| From | K <kalezwe@gmail.com> |
|---|---|
| Date | 2012-10-14 18:25 -0700 |
| Message-ID | <5bc3ab28-64fa-4edf-97b1-847a8c37c6f9@googlegroups.com> |
| In reply to | #19338 |
On Sunday, October 14, 2012 5:57:12 PM UTC-7, glen herrmannsfeldt wrote:
> K <kalezwe@gmail.com> wrote:
>
> > Why does my boolean statement have an error message next to it in eclipse?
>
>
>
> It should be a warning, not an error, but you never use the value
>
> of the variable. Eclipse nicely tells you that you might have
>
> forgotten something.
>
>
>
> -- glen
>
>
>
> > public class boolean1 {
>
>
>
> > public static void main(String[] args) {
>
> > int gumballs;
>
> > int kids;
>
> > int gumballsPerKid;
>
> > boolean eachKidGetsTen;
>
> >
>
> > gumballs = 140;
>
> > kids = 15;
>
> > gumballsPerKid = gumballs / kids;
>
> >
>
> > System.out.print("True of False? ");
>
> > System.out.println("Each kid gets 10 gumballs");
>
> > eachKidGetsTen = gumballsPerKid >= 10;
>
> > System.out.println("eachKidGetsTen");
>
>
>
> > }
what do you mean? How do you use the value of the variable? how would I fix my code?
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-10-14 21:34 -0700 |
| Message-ID | <2d3c7654-2100-4f9b-a764-1fb607bcaabc@googlegroups.com> |
| In reply to | #19340 |
K wrote: > what do you mean? How do you use the value of the variable? > how would I fix my code? http://docs.oracle.com/javase/tutorial/ -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> |
|---|---|
| Date | 2012-10-15 06:54 +0000 |
| Message-ID | <slrnk7ncom.u9l.avl@gamma.logic.tuwien.ac.at> |
| In reply to | #19340 |
K <kalezwe@gmail.com> wrote: > On Sunday, October 14, 2012 5:57:12 PM UTC-7, glen herrmannsfeldt wrote: >> K <kalezwe@gmail.com> wrote: >> > Why does my boolean statement have an error message next to it in eclipse? >> It should be a warning, not an error, but you never use the value >> of the variable. Eclipse nicely tells you that you might have >> forgotten something. > what do you mean? How do you use the value of the variable? > how would I fix my code? Since it's only a warning, you can just run the code and see the output. My guess is, you'll instantly spot the bug, and smile as the warning will disappear as a consequence of fixing the bug.
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2012-10-14 21:04 -0400 |
| Message-ID | <k5fnfp$1sm$1@dont-email.me> |
| In reply to | #19336 |
On 10/14/2012 8:44 PM, K wrote:
> Why does my boolean statement have an error message next to it in eclipse?
Probably because the variable `eachKidGetsTen' is not used.
It is given a value, but that value is never therafter consulted.
(For future reference: When you have a question about an
"error message," it is a good idea to quote the exact text of
the message. In this instance I imagine there was no text at
all, but still: Some description of the "error message" would
have been a good idea. As it is, I'm just guessing -- And, as
SH taught us, "It is a capital mistake to theorize before you
have all the evidence." But since I theorize ante-factually
only because you force me to, the offense is not mine but yours.
Off with your head!)
> public class boolean1 {
>
> public static void main(String[] args) {
> int gumballs;
> int kids;
> int gumballsPerKid;
> boolean eachKidGetsTen;
>
> gumballs = 140;
> kids = 15;
> gumballsPerKid = gumballs / kids;
>
> System.out.print("True of False? ");
> System.out.println("Each kid gets 10 gumballs");
> eachKidGetsTen = gumballsPerKid >= 10;
> System.out.println("eachKidGetsTen");
If you removed the " marks, I bet it would pacify Eclipse.
>
> }
>
> }
>
--
Eric Sosman
esosman@comcast-dot-net.invalid
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-10-14 18:52 -0700 |
| Message-ID | <duqm78p3p4p3pt0dkfln4i2clshngjj51m@4ax.com> |
| In reply to | #19339 |
On Sun, 14 Oct 2012 21:04:55 -0400, Eric Sosman
<esosman@comcast-dot-net.invalid> wrote:
>On 10/14/2012 8:44 PM, K wrote:
>> Why does my boolean statement have an error message next to it in eclipse?
>
> Probably because the variable `eachKidGetsTen' is not used.
>It is given a value, but that value is never therafter consulted.
(Your print statement does not refer to it.)
> (For future reference: When you have a question about an
>"error message," it is a good idea to quote the exact text of
>the message. In this instance I imagine there was no text at
>all, but still: Some description of the "error message" would
>have been a good idea. As it is, I'm just guessing -- And, as
>SH taught us, "It is a capital mistake to theorize before you
>have all the evidence." But since I theorize ante-factually
>only because you force me to, the offense is not mine but yours.
>Off with your head!)
What he said.
>> public class boolean1 {
>>
>> public static void main(String[] args) {
>> int gumballs;
>> int kids;
>> int gumballsPerKid;
>> boolean eachKidGetsTen;
>>
>> gumballs = 140;
>> kids = 15;
>> gumballsPerKid = gumballs / kids;
>>
>> System.out.print("True of False? ");
>> System.out.println("Each kid gets 10 gumballs");
>> eachKidGetsTen = gumballsPerKid >= 10;
>> System.out.println("eachKidGetsTen");
>
> If you removed the " marks, I bet it would pacify Eclipse.
Specifically,
eachKidGetsTen
and
"eachKidGetsTen"
are two very different things that just happen to resemble each other
textually.
>> }
>>
>> }
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | K <kalezwe@gmail.com> |
|---|---|
| Date | 2012-10-14 19:55 -0700 |
| Message-ID | <a88add70-2583-4769-9375-40f693e1a4e0@googlegroups.com> |
| In reply to | #19343 |
Thanks now my program works
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-10-14 20:10 -0700 |
| Message-ID | <vkvm781l4ia7g0v5itb421co25hginbeb1@4ax.com> |
| In reply to | #19344 |
On Sun, 14 Oct 2012 19:55:23 -0700 (PDT), K <kalezwe@gmail.com> wrote:
>Thanks now my program works
You are welcome.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Date | 2012-10-15 08:20 -0400 |
| Message-ID | <k5gulq$q2e$1@dont-email.me> |
| In reply to | #19344 |
On 10/14/2012 10:55 PM, K wrote: > Thanks now my program works, you may proceed.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-10-15 09:15 -0700 |
| Message-ID | <be41e326-9fba-4cdd-b43d-d64aa736bcd5@googlegroups.com> |
| In reply to | #19354 |
Jeff Higgins wrote: >K wrote: >> Thanks now my program works, you may proceed. Yeah, right? -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-10-14 22:41 -0700 |
| Message-ID | <sf8n78p52qmui6plhnm76ej10n83nvp967@4ax.com> |
| In reply to | #19336 |
On Sun, 14 Oct 2012 17:44:31 -0700 (PDT), K <kalezwe@gmail.com> wrote,
quoted or indirectly quoted someone who said :
>public class boolean1 {
>
> public static void main(String[] args) {
> int gumballs;
> int kids;
> int gumballsPerKid;
> boolean eachKidGetsTen;
Classes should start with a capital letter. See
http://mindprod.com/jgloss/codingconventions.html
eachKidGetsTen needs to be initialised.
--
Roedy Green Canadian Mind Products http://mindprod.com
The iPhone 5 is a low end Rolex.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-10-15 09:15 -0700 |
| Message-ID | <da605771-27d3-4a7d-84fa-5628b4ad21d6@googlegroups.com> |
| In reply to | #19349 |
Roedy Green wrote:
> K wrote, quoted or indirectly quoted someone who said :
>> public class boolean1 {
>>
>> public static void main(String[] args) {
>> int gumballs;
>> int kids;
>> int gumballsPerKid;
>> boolean eachKidGetsTen;
>
> Classes should start with a capital letter. See
> http://mindprod.com/jgloss/codingconventions.html
The normative document is the one on the Oracle site.
> eachKidGetsTen needs to be initialised.
Two things wrong with that advice. First, as written the program does not
require that the variable be initialized. Second, it is initialized in the
program the OP posted:
>> eachKidGetsTen = gumballsPerKid >= 10;
In the strict sense, it is not initialized but assigned here, but I take the
liberty of assuming you didn't mean it in the strict sense.
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Date | 2012-10-16 01:10 -0700 |
| Message-ID | <820a3276-36be-4d96-b539-68e2671840bb@googlegroups.com> |
| In reply to | #19336 |
On Monday, October 15, 2012 2:44:31 AM UTC+2, K wrote: > Why does my boolean statement have an error message next to it in eclipse? Just a general advice: it usually helps _a lot_ if you include the error you are seeing in your posting. You can even copy and paste it from Eclipse. http://www.catb.org/~esr/faqs/smart-questions.html Cheers robert
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web