mercredi 18 mars 2015

Assigning an already existing variable to another variable of a different type

I am currently stuck at a point in a program I have been working on: assigning an already existing variable to another variable of a different type. In my case, it would be int to ArrayList. For example:



int x = 3;
String string = "Bla Bla Bla";
List<String> myList = new LinkedList<String>(myList.asList(string.split(" "));

if(something){
//Delete x, and assign that same variable name (x) to myList so that myList is called x
}


P.S.: I am a very beginner to programming in Java, so please excuse my lack of knowledge on the matter! ;-)


Aucun commentaire:

Enregistrer un commentaire