Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

incompatible types *** have to convert String into char sequence

807599Feb 3 2007 — edited Feb 3 2007
The problem is i cant convert the string to char sequence using subSequence() .... I get the following error ... give me the solution ..

public class StrToChar
{
public static void main(String args[])
{
String str = args[0];
int slength = args[0].length();
char c[]=new char[slength];


for(int i=0;i<slength;i++)
{
c=str.subSequence(i,i+1);
System.out.println(c[i]);
}
} }

The error is ...

StrToChar.java:14: incompatible types
found : java.lang.CharSequence
required: char
c[i]=str.subSequence(i,i+1);
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 3 2007
Added on Feb 3 2007
1 comment
1,167 views