if we have to do the reverse process without using function then we can do it more easily with am empty string and for loop. String s="Saikat"; String rev=""; for(int i=s.length()-1;i>=0;i--){ rev += s.charAt(i); }
Whatever i will write for Shraddha is always a less. All i can say really appreciate for your effort to put across tough things in simpler way. And explanation in Hindi can be so good that i never thought off. Thanks to everyone who put there effort right from concept wise ,edit wise, teaching wise . You will definitely savior for many of us in terms of basic concepts clearing. kudos to entire team once again.
AT 22:47 we can also use this public static void main(String[] args) { String str = "this is a string"; String newstr = ""; for (int i = str.length()-1; i >= 0; i--) { newstr += str.charAt(i); } System.out.println(newstr); };
Please upload all the lecture ASAP . Waiting for Data Structure and Algorithm part..
Apna college's regular students will understand Shraddha didi's obsession with Tony Stark π ππ
finally i had completed till now.. thanks too you maam and sir β€
Easy Cheezzzyyyy π StringBuilder rev = new StringBuilder("Hello"); int i=0; int j=rev.length()-1; while(i<j){ char temp = rev.charAt(i); rev.setCharAt(i, rev.charAt(j)); // Set char at i rev.setCharAt(j, temp); i++; j--; } System.out.println(rev.toString());
For Reverse public class Main { public static void main(String[] args) { //Input Stirng Scanner sc = new Scanner(System.in); StringBuilder input = new StringBuilder(sc.next()); //Reverse String for(int i = input.length() - 1; i >= 0 ; i--) { System.out.print(input.charAt(i)); } } }
Ye aisa channel hai jise dekhker mujhe utni hi kushi hoti hai jaise kisi chote bacche ko Doraemon dekhker...ππππ
Hates off to @Apna_college :yt:. Really need this kind of contant . Thanks a lot.:elbowcough:
For reversing a string simplest way will be: StringBuilder sb = new StringBuilder("Tony"); StringBuilder sb1 = new StringBuilder(""); for(int i = sb.length()-1; i>=0; i--){ sb1.append(sb.charAt(i)); } System.out.println(sb1);
real fan of tony starkπ€£π
In String Builder there's direct method to reverse a string .,viz 'reverse()' System.out.println("Enter the string: "); String x = s.nextLine(); sb.append(x); System.out.println(sb.reverse());
We can do by this way also without using string builder function String str = "Harshita"; int len=str.length(); String r = ""; for(int i=len-1; i>=0; i--) { r=r+str.charAt(i); } System.out.println("Reversed string = "+r); } }
14:38 Reverse a String : StringBuilder str = new StringBuilder("APNA COLLEGE"); str.reverse(); System.out.println(str); OUTPUT: EGELLOC ANPA
19:48 Didi, we can also reverse a string by - public class sbTest{ public static void main(String[] args) { StringBuilder sb = new StringBuilder("hello"); StringBuilder newSb = new StringBuilder(" "); int j = 0; for(int i = sb.length()-1;i>=0;i--){ newSb.insert(j, sb.charAt(i)); j++; } System.out.print(newSb); }
just one suggestion in futre videos for any series please use one editor makes so much confusion between vs and intellij shortcuts
Thank you very much πβ€οΈ for providing such valuable information . Finally I'm able to learn coding π
We can also use reverse() method in StringBuilder to reverse a stringπ
@ansariafsar6995