Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-01-2007, 11:03 AM
Member
 
Join Date: Jun 2007
Posts: 21
ai_2007 is on a distinguished road
Doubt in edit and delete methods
Are these edit and delete methods correct?


Code:
**To delete bus number of any buses*/ public void deleteRecord(String busnum){ for(int i=0; i><buses.size(); i++){ Bus b = (Bus)buses.get(i); if((b.getBusnum()).compareTo(busnum)==0) buses.removeElementAt(i); } }

Code:
/**To edit record in the file*/ public void editRecord(String busnum){ for(int i=0; i><buses.size(); i++){ Bus b = (Bus)buses.get(i); if((b.getBusnum()).compareTo(busnum)==0){ buses.removeElementAt(i); } buses.insertElementAt((Object)i,1); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-01-2007, 11:09 AM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
The first one looks correct.

For the second one: instead of removing and reinserting a bus you should directly call object methods to change its properties!
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-01-2007, 11:55 AM
Member
 
Join Date: Jun 2007
Posts: 21
ai_2007 is on a distinguished road
Correction
I am not sure of how to do that. But is the below correct?

Code:
/**To edit record in the file*/ public void editRecord(String busnum){ for(int i=0; i><buses.size(); i++){ Bus b = (Bus)buses.get(i); if((b.getBusnum()).compareTo(busnum)==0){ buses.insertElementAt((Object)i,1); } }
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-01-2007, 12:40 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
I mean something like this:

Code:
/**To edit record in the file*/ public void editRecord(String busnum){ for(int i=0; i><buses.size(); i++){ Bus b = (Bus)buses.get(i); if((b.getBusnum()).compareTo(busnum)==0){ b.setName("New Bus"); } }
So in this example, i access the name property of a bus and change its name by calling its setName(String name) method. The method you need to call all depends on what you mean by editing!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't edit JTextField after modal dialog JavaNerd Java Applets 0 02-07-2008 10:11 PM
I need help with my java servlet homework(add,edit and delete) jellyfish888 Java Servlet 3 12-26-2007 07:42 AM
Edit JPanel Text During Runtime...from another class bdn1404 New To Java 5 08-11-2007 04:14 AM
how to edit lines. jason27131 New To Java 1 08-01-2007 05:41 AM
How To Edit/Add JSP Pages in NetBeans IDE JavaForums NetBeans 0 07-31-2007 12:13 AM


All times are GMT +3. The time now is 11:39 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org