Total members 11890 |It is currently Tue Apr 23, 2024 3:54 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





help me regarding StringBuffer.indexOf(String),i have tried both jdk1.4 and jdk1.6 for the following code to work..can any1 suggest me solution

Code:
psvm(String SubmitDate)
{
StringBuffer returnQuery  = new StringBuffer();
String dateString="";
returnQuery.append("SELECT * FROM ");
    returnQuery.append(view);
    returnQuery.append(userString);
    returnQuery.append(envString);
    returnQuery.append(requestidString);
    returnQuery.append(statusString);

    if((Submitdate==null) || (Submitdate.equals("")))
    {
        dateString="";
    }
    else if(returnQuery.indexOf("where")>0)
        dateString="  AND SUBMIT_DATE LIKE '"+Submitdate+"%'";
    else 
        dateString
=" WHERE SUBMIT_DATE LIKE '"+Submitdate+"%'";

}
 
iam getting error as the method indexOf(String) is undefined for type StringBuffer

Can any1 suggest me...




Author:
Newbie
User avatar Posts: 2
Have thanks: 0 time

There is no function called indexOf in the class StringBuffer

I suggest you use String instead of StringBuffer .And when you append you use the operator '+' .For example :
Code:
String name="Tom";
name+="AAA";
name+="aaa";


now the content of name is "TomAAAaaa"

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

I tried this code...
Code:
public static void main(String[] args) {
StringBuffer mybuff=new StringBuffer("Mohamed Sami");
mybuff.append(" ddd");
System.out.print(mybuff.indexOf("ddd"));


}


and the output is 13.... :grin:

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 3 posts ] 

  Related Posts  to : help me regarding StringBuffer.indexOf(String)
 difference between the String and StringBuffer     -  
 Read file content to StringBuffer String object     -  
 recursive string reversal- reverse string     -  
 Splitting a String Based on a Found String     -  
 check if string ends with specific sub-string in php     -  
 check if string start with a specific sub-string in PHP     -  
 String token for string split     -  
 Pad a string to a certain length with another string     -  
 get string length in asp     -  
 String to sql.Date     -  



Topic Tags

Java Strings
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com