+ 1

please find error

public class Program { public static void main(String[] args) { int i; string str=new string("Hey its my first program on java and my second learning day...!!!!!"); for(i=0;i<length.str();i++) { System.out.println(str[i]); Thread.sleep(5); } } }

12th Sep 2017, 2:20 PM
Ayush Thakur Eshu
Ayush Thakur Eshu - avatar
2 Antworten
+ 8
* string needs a capital S * length.str() is reversed. It should be str.length() * str[i] is not a valid syntax in java. (Because a string is not an array, and [] is only valid for arrays) Use charAt() instead Like: str.charAt(i)
12th Sep 2017, 2:27 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
import java.util.*; import java.lang.*; import java.io.*; public class Program extends Thread { public static void main(String[] args) { int i; String s1="Hey its my first program on java and my second learning day...!!!!!"; char[] str = s1.toCharArray(); int s = str.length; for(i=0;i<s;i++) { System.out.println(str[i]); } } } this code is working by using str[i]
12th Sep 2017, 8:04 PM
Ayush Thakur Eshu
Ayush Thakur Eshu - avatar