SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been working on trying to compile this bit of Java code. It's taken from an existing code (with permission) that I know works. The problems started when I added an array.

    Here's the code -
    Code:
    import java.net.*;
    import java.io.*;
    import java.awt.*;
    import com.stevesoft.pat.*;
    
    class GetBushed	{
    	public static void main (String[] arguments)	{
    		String[] bushArray = new bushArray[20];
    		try	{
    			URL url = new URL(
    				"http://www.cnn.com/");
    			BufferedReader bin = new BufferedReader(
    				new InputStreamReader (url.openStream() ));
    			String line;
    			Regex ba = new Regex("redhead\">(.*)<");
    			int i = 0;
    			while ( (line = bin.readLine()) !=null ){
    				if (ba.search(line))	{
    					bushArray[i] = ba.stringMatched(1);
    					i++;
    					}
    			}
    			
    		} catch (Exception e)	{}
    		for (int i = 0; i < bushArray.length; i++)	{
    			System.out.println("Bush's advantage is " + bushArray[3]);
    		}
    	}
    }
    Here's the error -
    Code:
    C:\jdk1.3>javac GetBushed.java
    GetBushed.java:8: cannot resolve symbol
    symbol  : class bushArray
    location: class GetBushed
                    String[] bushArray = new bushArray[20];
                                             ^
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is bushArray a class you already created/had?
    and why you declare a string array of bushArray[] ? Are they polymorphic?
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by 123finder.com
    Is bushArray a class you already created/had?
    and why you declare a string array of bushArray[] ? Are they polymorphic?
    No, bushArray is not a class I had already created.

    The original code used the regular expression to search and display the last matching result by default. I am trying insert each match into the array and then select a specific index number to display.
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  4. #4
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, so it shouldn't be bushArray objects.
    So the array declaration should be:
    String[] bushArray = new String[20]; // string object instead of bushArray, bushArray is only the pointer to the array of String

    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2000
    Location
    Palo Alto, CA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's not correct, it should be
    String[] bushArray = new String[20];
    Or if you have a data you would write:
    String[] whatever = new String[] {"dataValue","other"};
    watever[0] = dataValue, and so on.
    good luck.

  6. #6
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MY GOD!!

    It actuall worked. I am so ready to end this Java class.
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  7. #7
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL!
    So you taking a Java course?!
    Glad to see that java and I could give some help!
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •