I would like to store a Char in a Vector, but it doesnt like it, is there anyway of getting around this? Basically I have a program that returns maybe 5 or 6 chars, the last two are always duplicated say a, b, c, d, d, i dont want to solve this, but would like to say put them in a vector instead and just trim the vector down by one, to get a, b, c, d After i have a vector or a string i would then like to put them into a mysql database, what format is the best way to send them to a database? Hope this makes sense to someone Thanks T
There is no such thing as a "Char". There's a primitive type called "char", but you can't put a primitive in a Vector. That's what the wrapper classes like Integer (for int), Long, Float, Double, etc. are for. Try wrapping a char in a Character: vector.add(new Character(c)); To be honest though, I'm not sure you even need a vector here. If you always want to trim the last char in a String, just use substring(): String newStr = str.substring(0, str.length() - 1); To send to a database - well, using JDBC I suppose. If you've never used it, you can learn in this JDBC tutorial. Otherwise I'm not sure what you're asking.