473,667 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about java Collections

Hi.
I never worked with java's built-in collections framework, and I'm
having a bit of trouble with it.
I'm trying to pass a simple char data type into a
java.util.Linke dList, and I continue to get an incompatible type
exception (because it's expecting type Object). Is there a way I can
cast the char or set up the list so I can avoid this? I really dont
want to write a LinkedList class if one already exists.

BTW, I'm using the NetBeans IDE from the Sun website, if that means
anything.

Thanks.
Jul 17 '05 #1
3 3521
Joe
In article <52************ **************@ posting.google. com>,
sc****@comcast. net says...
I'm trying to pass a simple char data type into a
java.util.Linke dList, and I continue to get an incompatible type
exception (because it's expecting type Object).

Use the Character class in the java.lang package to wrap the char
prinmitive data before adding it the the Collection
Jul 17 '05 #2
Joe wrote:
In article <52************ **************@ posting.google. com>,
sc****@comcast. net says...

I'm trying to pass a simple char data type into a
java.util.Lin kedList, and I continue to get an incompatible type
exception (because it's expecting type Object).


Use the Character class in the java.lang package to wrap the char
prinmitive data before adding it the the Collection


You should also note that when you retrieve your data from the linked,
it will come in the form of a generic Object. You need to cast it back
to Character in order to extract your data from it.

Jul 17 '05 #3
Mitch Williams <co************ @cox.net> wrote in message news:<L0Ldb.766 7$Rd4.2521@fed1 read07>...
Joe wrote:
In article <52************ **************@ posting.google. com>,
sc****@comcast. net says...

I'm trying to pass a simple char data type into a
java.util.Lin kedList, and I continue to get an incompatible type
exception (because it's expecting type Object).


Use the Character class in the java.lang package to wrap the char
prinmitive data before adding it the the Collection


You should also note that when you retrieve your data from the linked,
it will come in the form of a generic Object. You need to cast it back
to Character in order to extract your data from it.


Nice thing is that with autoboxing facility to be introduced in JDK1.5
such painfully redundant syntax are eliminated.
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5564
by: mark | last post by:
I've been getting odd compile errors when trying to sort while using generics. I have the following code: static final List<Class> levelList; static { Vector<Class> v = new Vector<Class>(); v.add(myClass1.class);
8
1521
by: Ray | last post by:
Hello there, I've been programming in Java for about 8 years now, but lately I've been hearing a lot about Python and I'm really interested in learning more about it. I've read the tutorial, and some books (core python programming is one), but there's one thing that's still missing: how to use Python the "Python" way. I found learning C# was a breeze for me because the language shares a lot of concepts and notions with Java--I can...
25
3323
by: Digital Puer | last post by:
I'm looking at some software development jobs whose listings require C++ experience. My history is that I have a strong C background, and a few years of C++ from undergrad classes. I've been working with Java since 1997 and consider myself a decent Java programmer. Now, if I apply for C++ jobs, do you think it's important that I know the fine details of C++? or would a strong, generalised knowledge of object-oriented programming be more...
4
11936
by: 3rdshiftcoder | last post by:
Hi- I'd like to use this class from a book but am getting a compiler error. On the line private List < String > list; p.932 Chapter 19 found in the code below in the eclipse editor it is underlined in red. It is saying it is a syntax error and to delete the tokens. I'd like to use the code below in my program i am working on for my hobby. It will make life so much easier when i get past the compiler error.
0
3664
by: daniel li | last post by:
I got another convert issue. This is the same project as I posted yesterday, and received a perfect response. The conversion threw a SupportClass for me and one of the data type is CollectionSupport, this is to my understanding to replace Java.Util.Collection. In my code: public EcomWeb.rx_transactions.order.GroverOrder getGroverOrders(EcomWeb.domain.WebOrder webOrder) { System.Console.Out.WriteLine("OrderFactory. getGroverOrders( )...
458
21141
by: wellstone9912 | last post by:
Java programmers seem to always be whining about how confusing and overly complex C++ appears to them. I would like to introduce an explanation for this. Is it possible that Java programmers simply aren't smart enough to understand C++? This is not merely a whimsical hypothesis. Given my experience with Java programmers --- the code they write and the conversations they have --- Occam's Razor points to this explanation. For example,...
16
2119
by: coosa | last post by:
Dear all, I'm familiar with the Set Class in C++ and Java; however, i have been searching in C# for a similar container as in c++ or collection as in java, but couldn't find one. Could some one tell me about the the Set implementation inside .NET? Best regards
16
5101
by: 3rdshiftcoder | last post by:
hi- where would someone find things like lists, sets, map classes like a hash map or tree map. not specifically those but in general is there a book section that deals with it? in java you can use the interface to these without having to know all of the implementation details. is there an interface to a library with these kind of methods in c++? i knew a little c++ from 2 really basic introductory courses. however, each time we...
1
4653
by: raagadeepthi | last post by:
Getting below error when iam trying to sort the values: Oct 29 04:33:52 WARN cb.DefaultController - Cannot forward after response has been committed java.lang.IllegalStateException: Cannot forward after response has been committed at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:375) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:363) at...
0
8365
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8788
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8646
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7390
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6203
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.