Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Why the line Vector<String> result = new Vector<String>(respNum); is not ok????

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Why the line Vector<String> result = new Vector<String>(respNum); is not ok????

    static Vector findMatch(String str) {
    		Vector<String> result = new Vector<String>(respNum);
    		for(int i = 0; i < KnowledgeBase.length; ++i) {
    			if(KnowledgeBase[i][0].equalsIgnoreCase(str)) {
    				for(int j = inputNum; j <= respNum; ++j) {
    					result.add(KnowledgeBase[i][j]);
    				}
    				break;
    			}
    Last edited by helloworld922; December 22nd, 2010 at 12:31 PM.


  2. #2
    Junior Member
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Why the line Vector&ltString> result = new Vector&ltString>(respNum); is not ok??

    Vector<String> result = new Vector<String>(respNum);

    I corrected it

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Why the line Vector&ltString> result = new Vector&ltString>(respNum); is not ok??

    You'll have to define "not ok". Do you get an Exception? Does something else happen?

    And if you're posting code, make sure you use the code or highlight tags to preserve formatting. The code should be in the form of an SSCCE.

    If you do get an Exception in the SSCCE, copy and paste the stack trace here, pointing out any line numbers referenced so we don't have to count them ourselves.

Similar Threads

  1. [SOLVED] 2D Vector
    By nasi in forum Collections and Generics
    Replies: 2
    Last Post: May 6th, 2010, 01:42 AM
  2. String Vector
    By nasi in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 3rd, 2010, 11:45 PM
  3. Problem about Vector
    By tohid in forum Collections and Generics
    Replies: 1
    Last Post: March 26th, 2010, 01:44 PM
  4. byte[] from vector
    By perlWhite in forum Collections and Generics
    Replies: 1
    Last Post: August 26th, 2009, 05:10 AM
  5. vector
    By sriraj.kundan in forum Java Theory & Questions
    Replies: 8
    Last Post: August 12th, 2009, 10:17 AM