|
That one is not in and I bet the teacher doesn't tell.
|
|
|
|
|
There's two options: Either write some code to traverse the list and look at the ID, and if you get a match, remove that entry; or have your Employee's equals() method just use the ID. You should only do the second if you only ever want to compare Employees based on their ID (i.e. the ID is the only thing that identifies one), as it will make [2, "Joe", "Bangkok"] and [2, "Mary", "NYC"] match.
|
|
|
|
|
Your code could almost work.
First find the element, then remove it. Good practice is to never remove items from list while iterating through it and once you locate the required item to break.
public class DisplayArrayList {
public static void main(String[] args) throws Exception {
List<Employee> list = new ArrayList<Employee>();
list.add(new Employee(1, "A","Delhi"));
list.add(new Employee(2, "B","Mumbai"));
list.add(new Employee(3, "C","Chennai"));
list.add(new Employee(4, "D","Kolkata"));
System.out.println(" ");
System.out.print("Enter Employee Id: ");
Scanner input=new Scanner(System.in);
int id = input.nextInt();
Employee del = null;
for (Employee s : list) {
if(id == s.getId()) {
del = s;
break;
}
}
if (del != null) {
System.out.println("Name and Address of employee is: ");
System.out.print(s.getName()+" " +s.getAddress());
list.remove(del);
}
}
}
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
fine. hand over your book so I can give you a butterfly stamp.
And remember - when you have 5 stamps you do not need to do your homework that day.
|
|
|
|
|
Shan't!
One is bored. So bored writing documentation seems fun.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
plz friends,if any one knowns that about the mobile connectivity with java application.plz send me the source code..........i made java sms application which work to send sms to every one .....idont have any idea about mobile connectivity...plz help me.......
send me on this e-mail id.
acool47@yahoo.com
|
|
|
|
|
|
Got this code, and the teststring
class stringedit{
public static void main(string[]args){
String testString = "20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39";
String finalString="";
int testlength = testString.length();
for (int i=0;i<testlength;i++){
finalString = finalString+testString.substring(15)+"\n"
}
}
}
How do i get the finalString to be on 5 numbers each ?
|
|
|
|
|
You need to increment your loop counter by the length of the substring that you are extracting, and extract the next 15 characters starting at that index position. Try thinking about the mechanics of your program before you start the actual coding.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
class stringedit{
public static void main(string[]args){
String testString = "20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39";
String finalString="";
int testlength = testString.length();
for (int i=0;i<testlength;i++){
finalString = finalString+testString.substring(i,i+14)+"\n"
i+=14;
}
}
}
and problem solved and program working.
program is now asking for 20 numbers that gotta be in the range of 20 and 50. showInputDialog is popping up 20 times, if you enter one number outside the range it will not affect the program.
store each number in one array
print the numbers in one messagebox with 5 numbers on each line
all is now finally done =)
|
|
|
|
|
Hi,
I wanted to develop online shopping application in JAVA,
Could you please tell hoe the payment part is carried out, it connects to bank website, and does some encryption and all.
How will this be done.
Thanks in Advance
Anusha
|
|
|
|
|
This question is far too broad to be answered in a forum like this; try pasting your question into Google[^] and start researching some of the samples that are found.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
This is called a CMS - Content Management Service. There are several out there. I suggest to take one of them and develop a plugin to extend that CMS with a online shop.
Here you can test several Open Source CMS: http://www.opensourcecms.com/[^]
|
|
|
|
|
sir will u pls mail me....all or mostly implemented algo in cryptography in java language on my mail id i.e. ankigujjar@gmail.com
|
|
|
|
|
I think the answer is: No.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
This question is unlikely to get a reasonable answer. Firstly, you could find the answer by a simple Google search. secondly, this site does not provide code to order.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
Did you bother to read my previous answer? No-one is going to send you anything; Google is your friend here, make use of it.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Could i get an aplication to format a drive and create partition in java please?
|
|
|
|
|
Perhaps; but you will have to use Google to find it.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
|
i want to learn java programme, how do i start, can anybody help me out?
|
|
|
|
|
- install Eclipse IDE. It's free and while guide you through coding.
- install JDK (you probably already have done that)
- buy a good Book. Yes, they might cost some. But a book is great, because you can check out things without knowing exact "keywords".
and take a look here: http://docs.oracle.com/javase/tutorial/[^]
I would suggest to start with Console-Programs. They might look odd and making a GUI seems to be the goal, but to concentrate on the code and how things are made you should spare that out for the first time.
|
|
|
|