Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How find the data in ArrayList? 2011-12
#1
How find the data in ArrayList? 2011-12

i am write a New code in c++ who find the data in the array list
Code:
package student; import java.io.*; import java.util.*; public class StudentProtocol { private String id; private String name; private String module_name; private String marks; BufferedReader userInput=new BufferedReader(new InputStreamReader(System.in)); ArrayList<String> myArr =new ArrayList<String>(); //constructor public StudentProtocol(String id,String name,String module_name,String marks){ this.id=id; this.name=name; this.module_name=module_name; this.marks=marks; } // public String getId(){ return id; } public String getName(){ return name; } public String getModuleName(){ return module_name; } public String getMarks(){ return marks; } //mutator public void setId(String id){ this.id=id; } public void setName(String name){ this.name=name; } public void setModuleName(String module_name){ this.module_name=module_name; } public void setMarks(String marks){ this.marks=marks; } public void displayStudentDetails(){ System.out.println("ID is "+id); System.out.println("Name is "+name); System.out.println("Module name is "+module_name); System.out.println("Marks is "+marks); } public void addDetails()throws IOException{ BufferedReader userInput=new BufferedReader(new InputStreamReader(System.in)); ArrayList<String> myArr =new ArrayList<String>(); myArr.add(id); myArr.add(name); myArr.add(module_name); myArr.add(marks); System.out.println("Adding a new student"); System.out.println("Enter id:"); String id = userInput.readLine(); System.out.println("Enter name:"); String name = userInput.readLine(); System.out.println("Enter module name:"); String module_name = userInput.readLine(); System.out.println("Enter marks:"); String marks = userInput.readLine(); System.out.println("ID is "+id); System.out.println("Name is "+name); System.out.println("Module name is "+module_name); System.out.println("Marks is "+marks); } public void removeDetails(ArrayList<String> myArr) throws IOException{ displayStudentDetails(); //BufferedReader userInput = new BufferedReader (new InputStreamReader (System.in)); System.out.println("Please,enter a student id to delete:"); String id =userInput.readLine(); System.out.println("Size of array before removing item:"+myArr.size()); myArr.remove(myArr); System.out.println(id+"has been removed!"); System.out.println("Size of array after removing item:"+myArr.size()); } /*public void modifyDetails() throws IOException{ ArrayList<String> a= myArr; System.out.println(myArr); }*/ public static void main(String[] args, ArrayList<String> id) throws IOException { StudentProtocol s1= new StudentProtocol("89023","Rita","cse 3000Y","32.5"); s1.addDetails(); } }

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Send image to client over a socket in java 2011 Vuhelper 1 3,668 04-21-2012, 02:11 AM
Last Post: hoailenpro
  double buffering in java 2011-12 Vuhelper 0 2,196 09-12-2011, 10:30 PM
Last Post: Vuhelper
  Using wait and notify? in java 2011-12 Vuhelper 0 2,124 09-12-2011, 10:29 PM
Last Post: Vuhelper
  text wrap in java 2011-12 Vuhelper 0 2,134 09-12-2011, 10:27 PM
Last Post: Vuhelper
  TableModelListener ERROR in Java 2011 Vuhelper 0 2,026 07-23-2011, 05:47 PM
Last Post: Vuhelper
  Exception Handling in Java 2011 Vuhelper 0 1,975 07-23-2011, 05:46 PM
Last Post: Vuhelper
  Getting the element of a vector in Java 2011 Vuhelper 0 1,880 07-23-2011, 05:45 PM
Last Post: Vuhelper
  program does not enter for loop in Java 2011 Vuhelper 0 2,080 07-23-2011, 05:44 PM
Last Post: Vuhelper
  Editor does NOT contain a main type in Java 2011 Vuhelper 0 4,113 07-23-2011, 05:43 PM
Last Post: Vuhelper
  String to Char Array in Java 2011 Vuhelper 0 3,294 07-23-2011, 05:43 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)