Learning Java.....Need help
+2
madscientist032
JAMESTHEJRAGON
6 posters
Learning Java.....Need help
Ok so i have been watching Tuts on youtube on how to program with java i got everything working and im at variables...but "char" has not been working
Specificly
char letter = "A";
can someone explain what is wrong? I have been getting this error
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Duplicate local variable letter
Type mismatch: cannot convert from String to char
at BasicJava.main(BasicJava.java:14)
Any help is really appreciated :) thanks
-James
Specificly
char letter = "A";
can someone explain what is wrong? I have been getting this error
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Duplicate local variable letter
Type mismatch: cannot convert from String to char
at BasicJava.main(BasicJava.java:14)
Any help is really appreciated :) thanks
-James
JAMESTHEJRAGON- Lapis Miner
- Posts : 126
Join date : 2011-11-12
Re: Learning Java.....Need help
you cant use "A" as char. anything in double quotes is considered a string. Try 'a' instead. That might do the trick.
Thanks! I think that helped but now this....
That gave me a new error which is as follows (i know its a different line just added a few more lines of code in between there testing some math, tested it out works ok)
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
a cannot be resolved
at BasicJava.main(BasicJava.java:17)
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
a cannot be resolved
at BasicJava.main(BasicJava.java:17)
JAMESTHEJRAGON- Lapis Miner
- Posts : 126
Join date : 2011-11-12
Re: Learning Java.....Need help
What program are you using to write this out? I personally use Eclipse and Notepad++. Eclipse has a built-in feature that shows you where errors may occur in the code. This might help you out.
eclipse
I am also using eclipse, do i need to turn on this feature?
JAMESTHEJRAGON- Lapis Miner
- Posts : 126
Join date : 2011-11-12
Re: Learning Java.....Need help
No, it should be on by default. You'll see little squiggly lines (similar to those you'd see in Microsoft Word) under text. Red = will cause compilation error, yellow = should fix but will not cause code to error out.
Also don't forget your semicolons.
Also don't forget your semicolons.
semicolons :P gotta love em
I couldnt find tbe squiggly lines and the only error i get are after i try to run it at the bottom of the screen
currently more frustrated with my ipod not scanning that code thing at the top of the home screen for oasis :P lol
currently more frustrated with my ipod not scanning that code thing at the top of the home screen for oasis :P lol
JAMESTHEJRAGON- Lapis Miner
- Posts : 126
Join date : 2011-11-12
Re: Learning Java.....Need help
http://lmgtfy.com/?q=c%2B%2BJAMESTHEJRAGON wrote:What is C++????
BroadStreetBully- Professional Miner
- Posts : 1349
Join date : 2011-05-09
Age : 1024
Re: Learning Java.....Need help
C++ is an object oriented programming language that takes forever to program with as you have to manually manage memory. Stick with java.
char letter = 'A';
And, as said before anything in quotation marks is a string.
char letter = 'A';
And, as said before anything in quotation marks is a string.
evilmidget38- Iron Miner
- Posts : 60
Join date : 2011-06-06
Age : 26
Re: Learning Java.....Need help
OMG, how do you make something like that. I also like how it takes you to the search.BroadStreetBully wrote:http://lmgtfy.com/?q=c%2B%2BJAMESTHEJRAGON wrote:What is C++????
lordgonk- Diamond Miner
- Posts : 663
Join date : 2011-07-13
Age : 26
Permissions in this forum:
You cannot reply to topics in this forum
|
|
1/11/2022, 7:11 pm by Revilo410
» I've mined my final block. Thanks for the memories!
1/10/2022, 5:31 pm by madscientist032
» Shop :))
1/10/2022, 3:54 pm by Natalie220505
» Persephone's Application for Staff
1/8/2022, 6:39 pm by Tino6145
» Chx_Cat's member application
1/6/2022, 11:42 am by Beigecheetah485
» Rebeka_5's Oasian application
1/3/2022, 11:35 pm by Trai1
» Clausimodo Staff Application :)
1/2/2022, 1:14 am by halycone
» Application for member
1/1/2022, 7:36 pm by _Cepo
» Zaba's (really late) Introduction
1/1/2022, 8:53 am by halycone
» Zaba's Staff App
12/31/2021, 8:03 pm by King_Ralphio