Learning Java.....Need help

+2
madscientist032
JAMESTHEJRAGON
6 posters

Go down

Learning Java.....Need help  Empty Learning Java.....Need help

Post by JAMESTHEJRAGON 1/18/2012, 10:21 pm

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

JAMESTHEJRAGON
JAMESTHEJRAGON
Lapis Miner
Lapis Miner

Posts : 126
Join date : 2011-11-12

Back to top Go down

Learning Java.....Need help  Empty Re: Learning Java.....Need help

Post by madscientist032 1/18/2012, 10:27 pm

you cant use "A" as char. anything in double quotes is considered a string. Try 'a' instead. That might do the trick.
madscientist032
madscientist032
Oasis SMP Owner
Oasis SMP Owner

Posts : 5000
Join date : 2011-02-09
Age : 32

https://www.youtube.com/user/madscientist032

Back to top Go down

Learning Java.....Need help  Empty Thanks! I think that helped but now this....

Post by JAMESTHEJRAGON 1/18/2012, 10:33 pm

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)
JAMESTHEJRAGON
JAMESTHEJRAGON
Lapis Miner
Lapis Miner

Posts : 126
Join date : 2011-11-12

Back to top Go down

Learning Java.....Need help  Empty Re: Learning Java.....Need help

Post by madscientist032 1/18/2012, 10:35 pm

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.
madscientist032
madscientist032
Oasis SMP Owner
Oasis SMP Owner

Posts : 5000
Join date : 2011-02-09
Age : 32

https://www.youtube.com/user/madscientist032

Back to top Go down

Learning Java.....Need help  Empty eclipse

Post by JAMESTHEJRAGON 1/18/2012, 10:36 pm

I am also using eclipse, do i need to turn on this feature?
JAMESTHEJRAGON
JAMESTHEJRAGON
Lapis Miner
Lapis Miner

Posts : 126
Join date : 2011-11-12

Back to top Go down

Learning Java.....Need help  Empty Re: Learning Java.....Need help

Post by madscientist032 1/18/2012, 10:50 pm

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.
madscientist032
madscientist032
Oasis SMP Owner
Oasis SMP Owner

Posts : 5000
Join date : 2011-02-09
Age : 32

https://www.youtube.com/user/madscientist032

Back to top Go down

Learning Java.....Need help  Empty semicolons :P gotta love em

Post by JAMESTHEJRAGON 1/18/2012, 10:55 pm

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
JAMESTHEJRAGON
JAMESTHEJRAGON
Lapis Miner
Lapis Miner

Posts : 126
Join date : 2011-11-12

Back to top Go down

Learning Java.....Need help  Empty Re: Learning Java.....Need help

Post by Kingnothing_01 1/18/2012, 11:43 pm

screw java get c++
Kingnothing_01
Kingnothing_01
Redstone Miner
Redstone Miner

Posts : 207
Join date : 2010-11-21

http://TheAmazingBrandO.com

Back to top Go down

Learning Java.....Need help  Empty c++?

Post by JAMESTHEJRAGON 1/19/2012, 11:15 am

What is C++????
JAMESTHEJRAGON
JAMESTHEJRAGON
Lapis Miner
Lapis Miner

Posts : 126
Join date : 2011-11-12

Back to top Go down

Learning Java.....Need help  Empty Re: Learning Java.....Need help

Post by BroadStreetBully 1/19/2012, 3:47 pm

JAMESTHEJRAGON wrote:What is C++????
http://lmgtfy.com/?q=c%2B%2B

BroadStreetBully
Professional Miner
Professional Miner

Posts : 1349
Join date : 2011-05-09
Age : 1024

Back to top Go down

Learning Java.....Need help  Empty Re: Learning Java.....Need help

Post by evilmidget38 1/19/2012, 5:24 pm

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.

evilmidget38
Iron Miner
Iron Miner

Posts : 60
Join date : 2011-06-06
Age : 26

Back to top Go down

Learning Java.....Need help  Empty Re: Learning Java.....Need help

Post by lordgonk 1/19/2012, 7:07 pm

BroadStreetBully wrote:
JAMESTHEJRAGON wrote:What is C++????
http://lmgtfy.com/?q=c%2B%2B
OMG, how do you make something like that. I also like how it takes you to the search.
lordgonk
lordgonk
Diamond Miner
Diamond Miner

Posts : 663
Join date : 2011-07-13
Age : 26

Back to top Go down

Learning Java.....Need help  Empty Re: Learning Java.....Need help

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum