Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Compiler Issues  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I'm having an issue compiling several programs that use StdDraw and the Draw classes. I am in AP Comp Sci A and have a decent understanding of java so far and this problem is beyond me and my teacher doesn't seem to know the issue as well. This error keeps occurring whenever I try to compile programs that use the Draw and StdDraw class.

javac StdDraw.java  -Xdiags:verbose
StdDraw.java:1965: error: incompatible types: Character cannot be converted to char
           return keysTyped.remove(keysTyped.size() - 1);
                                  ^
StdDraw.java:1995: error: method addFirst in class LinkedList<E> cannot be applied to given types;
           keysTyped.addFirst(e.getKeyChar());
                    ^
 required: Character
 found: char
 reason: argument mismatch; char cannot be converted to Character
 where E is a type-variable:
   E extends Object declared in class LinkedList
2 errors

I am running java 9 so this should autobox or unbox and it's obviously not. Linked here are the Standard libraries and StdDraw is listed there. Thank you and I appreciate any and all help.
 
Marshal
Posts: 63837
209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please show us the offending code.
 
Sheriff
Posts: 13386
221
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Emry hankins wrote:Linked here are the Standard libraries and StdDraw is listed there.



Welcome to the Ranch!

Presumably, you are referring to a version of this: https://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/StdDraw.java
 
Emry hankins
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Junilu Lacar wrote:

Emry hankins wrote:Linked here are the Standard libraries and StdDraw is listed there.



Welcome to the Ranch!

Presumably, you are referring to a version of this: https://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/StdDraw.java



yes this is the version I'm talking about.
 
Saloon Keeper
Posts: 9997
208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like a classic case of having a custom class with the same name as one from the standard API.

Did you create a class named Character?
 
Emry hankins
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Looks like a classic case of having a custom class with the same name as one from the standard API.

Did you create a class named Character?



Yes thank you! It was such a simple mistake. Thank you all for your help!
 
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!