Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try </p> <pre><code>StringTokenizer st = new StringTokenizer((String) buf,","); </code></pre> <p>The reason why you're getting that error is because <code>buf</code>, while referring to a <code>String</code> at that point, is still of type <code>Object</code>.</p> <hr> <p>As an additional tip, you really should make the effort to try to understand the error message given by the compiler. Look at the following:</p> <pre><code>cannot find symbol constructor StringTokenizer(java.lang.Object,java.lang.String) location: class java.util.StringTokenizer st = new StringTokenizer(buf,","); </code></pre> <p>Compiler error messages don't always make sense, but <strong>this is as good as it gets</strong>. It tells you that:</p> <ul> <li>It found the right type, <code>java.util.StringTokenizer</code>, so it's not an <code>import</code> or name obscuring problem, etc.</li> <li>It's telling you that a specific method with the given signature can not be found. Indeed, a quick check with the API confirms that <code>StringTokenizer</code> does NOT have a constructor that takes a <code>(java.lang.Object, java.lang.String)</code>.</li> <li>It's telling you <em>exactly the line of code in your program</em> that tries to invoke this non-existent method. And <em>indeed</em>, the type of your first argument is a <code>java.lang.Object</code>, and the type of your second argument is a <code>java.lang.String</code>!!!</li> </ul> <p>That was how I was able to quickly pinpoint the problem in the source code and suggest a quick fix.</p> <p>Being able to process error messages given by the compiler is <strong>an essential skill</strong> that you must develop, so I hope this proves to be an educational experience for you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload