Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
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-13-2007, 11:16 AM
Member
 
Join Date: Jul 2007
Posts: 3
ulykidjoe is on a distinguished road
Unify these 3 lines of code
Hi people,
I have these codes:
Code:
java.util.Vector columns = new java.util.Vector(); columns.addElement("..#directory"); rows.insertElementAt(columns, 0);
I Would like to write them in just one line of code like
Code:
rows.insertElementAt(new java.util.Vector() ..., 0)
by i dont know the correct syntax.
Can you help me.
Thanks a lot.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-13-2007, 12:44 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
Try this:

Code:
rows.insertElementAt((new Vector()).addElement("..#directory"), 0);
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-13-2007, 12:52 PM
Member
 
Join Date: Jul 2007
Posts: 3
ulykidjoe is on a distinguished road
Thanks for Your reply but im getting an error: "'void' type not allowed here." with your code, what might be wrong??
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-13-2007, 01:22 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
Hmm, that is right addElement method returns void and you can not add void to rows vector.

You can't do that in one line because Vector constructor does not accept the first element of the vector as a parameter. You should use at least three lines like you have given.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-13-2007, 03:15 PM
Member
 
Join Date: Jul 2007
Posts: 3
ulykidjoe is on a distinguished road
Okay thank you very much for your time, now at least i can rest in peace
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
How to get the count of all the lines in a file Java Tip java.io 0 04-06-2008 09:45 PM
how can we remove blank lines from a .txt Camden New To Java 1 03-12-2008 08:02 AM
Removing empty lines from code using Eclipse javaplus Eclipse 1 12-14-2007 11:21 PM
Joining lines in Eclipse Java Tip Java Tips 0 12-04-2007 01:17 PM
how to edit lines. jason27131 New To Java 1 08-01-2007 06:41 AM


All times are GMT +3. The time now is 03:54 PM.


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