arraylist

List<String> to ArrayList<String> conversion issue

徘徊边缘 提交于 2020-11-30 02:55:19
问题 I have a following method...which actually takes the list of sentences and splits each sentence into words. Here is it: public List<String> getWords(List<String> strSentences){ allWords = new ArrayList<String>(); Iterator<String> itrTemp = strSentences.iterator(); while(itrTemp.hasNext()){ String strTemp = itrTemp.next(); allWords = Arrays.asList(strTemp.toLowerCase().split("\\s+")); } return allWords; } I have to pass this list into a hashmap in a following format HashMap<String, ArrayList

List<String> to ArrayList<String> conversion issue

[亡魂溺海] 提交于 2020-11-30 02:54:26
问题 I have a following method...which actually takes the list of sentences and splits each sentence into words. Here is it: public List<String> getWords(List<String> strSentences){ allWords = new ArrayList<String>(); Iterator<String> itrTemp = strSentences.iterator(); while(itrTemp.hasNext()){ String strTemp = itrTemp.next(); allWords = Arrays.asList(strTemp.toLowerCase().split("\\s+")); } return allWords; } I have to pass this list into a hashmap in a following format HashMap<String, ArrayList

List<String> to ArrayList<String> conversion issue

烂漫一生 提交于 2020-11-30 02:54:17
问题 I have a following method...which actually takes the list of sentences and splits each sentence into words. Here is it: public List<String> getWords(List<String> strSentences){ allWords = new ArrayList<String>(); Iterator<String> itrTemp = strSentences.iterator(); while(itrTemp.hasNext()){ String strTemp = itrTemp.next(); allWords = Arrays.asList(strTemp.toLowerCase().split("\\s+")); } return allWords; } I have to pass this list into a hashmap in a following format HashMap<String, ArrayList

How to pass a list variable into a constructor/method

感情迁移 提交于 2020-11-30 00:01:35
问题 I'm new to Java. I'm having issues passing a List variable that is part of a constructor definition when I created an object of the class public class Patient { private String patientfirstName; private String patientLastName; private List<String> allergyList; public Patient(String patientfirstName, String patientLastName, List<String> allergyList) { this.patientfirstName = patientfirstName; this.patientLastName = patientLastName; this.allergyList = allergyList; } Patient patientobj = new

How to pass a list variable into a constructor/method

蓝咒 提交于 2020-11-30 00:00:14
问题 I'm new to Java. I'm having issues passing a List variable that is part of a constructor definition when I created an object of the class public class Patient { private String patientfirstName; private String patientLastName; private List<String> allergyList; public Patient(String patientfirstName, String patientLastName, List<String> allergyList) { this.patientfirstName = patientfirstName; this.patientLastName = patientLastName; this.allergyList = allergyList; } Patient patientobj = new

How to pass a list variable into a constructor/method

风流意气都作罢 提交于 2020-11-29 23:58:49
问题 I'm new to Java. I'm having issues passing a List variable that is part of a constructor definition when I created an object of the class public class Patient { private String patientfirstName; private String patientLastName; private List<String> allergyList; public Patient(String patientfirstName, String patientLastName, List<String> allergyList) { this.patientfirstName = patientfirstName; this.patientLastName = patientLastName; this.allergyList = allergyList; } Patient patientobj = new

How to pass a list variable into a constructor/method

久未见 提交于 2020-11-29 23:56:59
问题 I'm new to Java. I'm having issues passing a List variable that is part of a constructor definition when I created an object of the class public class Patient { private String patientfirstName; private String patientLastName; private List<String> allergyList; public Patient(String patientfirstName, String patientLastName, List<String> allergyList) { this.patientfirstName = patientfirstName; this.patientLastName = patientLastName; this.allergyList = allergyList; } Patient patientobj = new

Adding new objects to an ArrayList in constructor

懵懂的女人 提交于 2020-11-28 02:54:37
问题 I am trying to add newly created objects to an ArrayList in the constructor of a class. The new objects are being created in another class in the main method. Main method: public static void main(String[] args) { // TODO code application logic here Player p1 = new Player("Peter"); } My Player class: public class Player { protected static int age; protected static String name; protected static ArrayList players = new ArrayList(); Player(String aName) { name = aName; age = 15; players.add(new

Adding new objects to an ArrayList in constructor

旧街凉风 提交于 2020-11-28 02:54:27
问题 I am trying to add newly created objects to an ArrayList in the constructor of a class. The new objects are being created in another class in the main method. Main method: public static void main(String[] args) { // TODO code application logic here Player p1 = new Player("Peter"); } My Player class: public class Player { protected static int age; protected static String name; protected static ArrayList players = new ArrayList(); Player(String aName) { name = aName; age = 15; players.add(new

Adding new objects to an ArrayList in constructor

我的梦境 提交于 2020-11-28 02:54:08
问题 I am trying to add newly created objects to an ArrayList in the constructor of a class. The new objects are being created in another class in the main method. Main method: public static void main(String[] args) { // TODO code application logic here Player p1 = new Player("Peter"); } My Player class: public class Player { protected static int age; protected static String name; protected static ArrayList players = new ArrayList(); Player(String aName) { name = aName; age = 15; players.add(new