Learning Java.....Need help

View previous topic View next topic Go down

Learning Java.....Need help

Post by JAMESTHEJRAGON on 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
Lapis Miner
Lapis Miner

Posts : 127
Join date : 2011-11-12

View user profile

Back to top Go down

Re: Learning Java.....Need help

Post by madscientist032 on 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
Oasis SMP Owner
Oasis SMP Owner

Posts : 3763
Join date : 2011-02-09
Age : 25
Location : Black Mesa Research Facility, New Mexico

View user profile http://www.youtube.com/user/madscientist032

Back to top Go down

Thanks! I think that helped but now this....

Post by JAMESTHEJRAGON on 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
Lapis Miner
Lapis Miner

Posts : 127
Join date : 2011-11-12

View user profile

Back to top Go down

Re: Learning Java.....Need help

Post by madscientist032 on 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
Oasis SMP Owner
Oasis SMP Owner

Posts : 3763
Join date : 2011-02-09
Age : 25
Location : Black Mesa Research Facility, New Mexico

View user profile http://www.youtube.com/user/madscientist032

Back to top Go down

eclipse

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

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

JAMESTHEJRAGON
Lapis Miner
Lapis Miner

Posts : 127
Join date : 2011-11-12

View user profile

Back to top Go down

Re: Learning Java.....Need help

Post by madscientist032 on 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
Oasis SMP Owner
Oasis SMP Owner

Posts : 3763
Join date : 2011-02-09
Age : 25
Location : Black Mesa Research Facility, New Mexico

View user profile http://www.youtube.com/user/madscientist032

Back to top Go down

semicolons :P gotta love em

Post by JAMESTHEJRAGON on 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
Lapis Miner
Lapis Miner

Posts : 127
Join date : 2011-11-12

View user profile

Back to top Go down

Re: Learning Java.....Need help

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

screw java get c++

Kingnothing_01
Redstone Miner
Redstone Miner

Posts : 207
Join date : 2010-11-21
Location : Cactus, Desert

View user profile http://TheAmazingBrandO.com

Back to top Go down

c++?

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

What is C++????

JAMESTHEJRAGON
Lapis Miner
Lapis Miner

Posts : 127
Join date : 2011-11-12

View user profile

Back to top Go down

Re: Learning Java.....Need help

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

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

BroadStreetBully
Professional Miner
Professional Miner

Posts : 1352
Join date : 2011-05-09
Age : 1016
Location : PA

View user profile

Back to top Go down

Re: Learning Java.....Need help

Post by evilmidget38 on 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 : 19

View user profile

Back to top Go down

Re: Learning Java.....Need help

Post by lordgonk on 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
Diamond Miner
Diamond Miner

Posts : 678
Join date : 2011-07-13
Age : 19
Location : Collegeville Pa (Right near Valley Forge)

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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