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.
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);
import java.util.*; public class reverseString { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String word= sc.next(); for(int i=word.length()-1;i>=0;i--) { System.out.print(word.charAt(i)); } } } this is also a another way and easy also.
@@soumyajitghosh9055 arey Bhai 😂...me real time interview experience Ka Bola ...interview me Bina function use kiye Karke dikhao Karke puchenge... interviewers check your logic ... Jo bhi function Tu use karega na ..wo function create Karne keliye BHI logic chayiye na 😂...when you develop something from scratch ,you need to build logic for that problem to get solution ... they check how well you can build your problem solutions
@@mdakhan7400 this one is better then StringBuilder sb = new StringBuilder("Tony Stark"); for(int i=sb.length(); i>=0; i--) { System.out.print(sb.chatAt(i)); }
@@shaikasad-yn8he int i = 0; i < sb.length() - 1; i++; Just reverse it, start from last index and go to 1st index like int i = sb.length() - 1; i >= 0; i--;
public class Strings{ public static void main(String[]args){ String builder r =new StringBuilder("Apana College"); System.out.println(r.reverse()); } } 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); }
she is showing how to reverse in the same string variable .... if we have to use other variable then there is no need of setbuilder so that's why she presented in that way
for reversing the string you can also do this simple method class FirstClass { public static void main(String[] args) { StringBuilder name = new StringBuilder("Hello"); for(int i = name.length()-1;i>=0;i--){ System.out.print(name.charAt(i)); }}}
it is not actually replacing the string your are just printing theme in reverse order.which it is still same in the code you just show character by character in the reverse order on the console without nextline
@@nitinduke this will help String name="hello"; StringBuilder name2=new StringBuilder(""); int size=name.length()-1; for(int i=size;i>=0;i--){ name2.append(name.charAt(i)); } System.out.println(name2); yeh easy hai but didi ka efficient hai bcoz it has n/2 iterations and this code has n iterations..
@@shaikasad-yn8he basically when someone does length()-1 tho yeh Samaj lena ki length() function jo output dega usse 1 minus ho rha hai. For example name="rahul" Name.length() karne pe rahul name ka length miljayega.. abhi yeh length ko aap apne loop me kaise use karenge wo aap pe depend hai. You can do -1,-2 ,-3 Kitna bhi minus kar sakte ho .use it according to your needs
Instead of front and back character we can simply do reverse for loop and return the reverse string using charAt public class reverstring { public static void main(String[] args) { StringBuilder sb=new StringBuilder("nayra");
System.out.println(sb); int n=sb.length(); for(int i=n-1;i>=0;i--){ System.out.print(sb.charAt(i)); it will display "aryan"
At 17:00 we can also do by using for loop is just reverse direction like initialising by { name.lengthI()-1 to 0 } considering name as out String and just print 🙃🙃🙃🙃
@@earthlover449 i think this is what he meant --------> String name="hello"; StringBuilder name2=new StringBuilder(""); int size=name.length()-1; for(int i=size;i>=0;i--){ name2.append(name.charAt(i)); } System.out.println(name2); but jo didi ne sikhaya usme kam iterations use hote hai (n/2)...isme n iterations use hote hai...difference is vast when input is big..aisa lagta hai
@@swarajhegde9059 bhai isme string reverse nehi hua, given string ki value dusri string mein reverse order mein store hua.. given string ka order same hi reh gaya
It is just printing , in video mam has done how to actually reverse the main string ... in your loop as soon as the loop ends ... string gets back to its original value
SIMPLE WAY TO REVERSE STRING : String name = "Himanshu"; int m = name.length(); String reverse = ""; for (int i = m - 1; i >= 0; i--) { reverse += name.charAt(i); } System.out.println(reverse);
we can also write in these form:- import java.util.*; public class Main{ public static void main (String[] args) { String b = ""; Scanner s = new Scanner(System.in); String a = s.next(); for(int i=a.length();i>0;i--){ b+=a.charAt(i-1); } System.out.println(b); } }
For reversing all characters of a string can also be done by import java.util.Scanner; public class javaArray { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); StringBuilder sb = new StringBuilder(str); int len = sb.length(); for(int i=len-1;i>=0;i--) { System.out.print(sb.charAt(i)+" "); } } }
reversing the string can be done very simply with a basic logic public class str4 { public static void main(String[] args) { String str = "hello"; int length = str.length(); for(int i = length-1;i>=0;i--){ System.out.print(str.charAt(i)); } } }
I think this will be more easiest way to reverse a String.... public static void main(String[] args) { String a = "Geet"; for(int i = a.length() - 1 ; i >= 0 ; i --){ System.out.print(a.charAt(i)); } }
I do this question in my style import java.util.*; public class learning{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); String name = "Hello"; int i = name.length(); while(i > 0){ i = i -1; System.out.print(name.charAt(i)); } } }
i used this logic 🙄 StringBuilder st=new StringBuilder("helllllo"); for (int i=st.length()-1;i>=0;i--) { System.out.println(st.charAt(i)); } ik its gonna print line by line... but logic seems comfortable
For reverce String this short cut method public static String ReverceString(String str){ for (int i=str.length()-1; i>=0; i--){ System.out.print(str.charAt(i)); } return str; }
We can reverse String without StringBuilder. But we have to make a new String. import java.util.*; public class ReverseString { public static void main(String[] args){ Scanner sc = new Scanner(System.in); String str = sc.nextLine(); String newStr = ""; for(int i=str.length()-1; i>=0; i--){ newStr += str.charAt(i); } System.out.println(newStr); } }
Aslam o Alikum i am from pakistan apke video se main boht kujh sekh rah ho i love sis agr main sucesses hogya to apse milne zoror aoga, I love sis Allah Apko Khush rakhi or Aman Bhai ko😍🥰
public static void main(String args[]) { StringBuilder str = new StringBuilder("hello"); for (int i = (str.length() - 1); i >= 0; i--) { System.out.print(str.charAt(i)); } str.reverse(); System.out.print(str); } more easy and simple code in single line
Really thnks alot dii...Really means a lot ...wait for last 2 days ki kab aayagi apki video 😁....but np aap ka kaam bhi simple nhii hai..to explain in such a simplified way...🤗
REVERSE STRING USING STRING BUILDER :: public class reverseStringBuilder { public static void main(String[] args) { StringBuilder sb = new StringBuilder("Hell"); for (int i = 0; i
Didi I used a for loop for whole length for reversing and the method which you gave. the time complexity did not reduce by half. first one was 3s 454 ms and second one was 3s 745 ms
8:50 to anyone facing error during this code which looks like this: java: incompatible types: java.lang.String cannot be converted to char then just change the character to 'P' from "P" in the setCharAt function.. I am also new to java and i think apparently java considers " " to be Strings and ' ' to be Character (Char)..
Are hum ya pe reverse for loop bhi to use kr skte hai..... String name = "Varun"; for(int i = name.length()-1; i>=0; i--){ System.out.print( name.charAt( i ) ) ; } //Output == nuraV 👍👍👍
finally I'm completed my core java, lots of respect/appreciation to you shraddha mam & your team 👍
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);
}
sb.reverse();
sout(sb);
😀
is much more easy.....
StringBuilder sb=new StringBuilder ("hello");
sb.reverse();
System.out.println(sb);
@@bhat_hazimlol😂
bro it's time complexity and space complexity is more than the code givn by mam
Good.
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.
finally i had completed till now..
thanks too you maam and sir ❤
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);
Maybe simplest but not optimized, takes more time and memory.
We can also do it without creating an extra stringbuilder , just by editing on the same stringbuilder ig.... that's more efficient and memory saving
import java.util.*;
public class reverseString
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
String word= sc.next();
for(int i=word.length()-1;i>=0;i--)
{
System.out.print(word.charAt(i));
}
}
}
this is also a another way and easy also.
You are storing one String to another one, not reversing.
I also thought of similar logic, but most efficient way is to just create a StringBuilder and use reverse() method
Easy Cheezzzyyyy 😊
StringBuilder rev = new StringBuilder("Hello");
int i=0; int j=rev.length()-1;
while(i
We can also use reverse() method in StringBuilder to reverse a string😁
HAHA! Mene bhi reverse () function hi use Kia tha phir me yeh Soch rha tha keh yeh itna bara code kue likh rhi ha..
@@saadmayo8822 arey matlab job interviews me without functions karna padta hai bro...They will test your logic building ability
🤣 mein bhi use kia reverse()
@@swarajhegde9059 bro Agar ek 10 min ka kam pe tum pura din leloge toh koi tumhe job nhi dega.
@@soumyajitghosh9055 arey Bhai 😂...me real time interview experience Ka Bola ...interview me Bina function use kiye Karke dikhao Karke puchenge... interviewers check your logic ... Jo bhi function Tu use karega na ..wo function create Karne keliye BHI logic chayiye na 😂...when you develop something from scratch ,you need to build logic for that problem to get solution ... they check how well you can build your problem solutions
After watching multiple videos,I finally understood to reverse a string through your video
Please upload all the lecture ASAP . Waiting for Data Structure and Algorithm part..
1) Reverse String using string builder using inbuilt function.
String s2= String.valueOf(s1.reverse());
System.out.println(s2);
She taught us without using any function bro with the help of loops and basic method but yeah a function could be used for time complexity
@@mdakhan7400 this one is better then
StringBuilder sb = new StringBuilder("Tony Stark");
for(int i=sb.length(); i>=0; i--) {
System.out.print(sb.chatAt(i));
}
@@AmarKumar-nf3nn sb.length()-1* and sb.charAt(i)*
@@AmarKumar-nf3nn bhai iss loop ko explain karo thoda sa plz
for(int i=word.length()-1;i>=0;i--)
@@shaikasad-yn8he int i = 0; i < sb.length() - 1; i++;
Just reverse it, start from last index and go to 1st index like
int i = sb.length() - 1; i >= 0; i--;
Thank you very much 💐❤️ for providing such valuable information . Finally I'm able to learn coding 😀
Frm where u studied??
@@RajanGupta-cj4zm from this channel
ruclips.net/video/VNBhtuEfs9U/видео.html
Ye aisa channel hai jise dekhker mujhe utni hi kushi hoti hai jaise kisi chote bacche ko Doraemon dekhker...🎉🎉😀😀
public class Strings{
public static void main(String[]args){
String builder r =new StringBuilder("Apana College");
System.out.println(r.reverse());
}
}
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);
}
🎉🎉
Thanks buddy
she is showing how to reverse in the same string variable .... if we have to use other variable then there is no need of setbuilder so that's why she presented in that way
StringBuilder opposite=new StringBuilder(hello);
opposite.reverse();
System.out.println(opposite);
ye zada asan hai bhai
🎉🎉🎉🎉🎉
Aapse to koi begginner wala insaaan kbhi seekh hi nhi skta kuch.
Apna college's regular students will understand Shraddha didi's obsession with Tony Stark 😅😂😂
Didi please upload all the lectures as fast as you can.
Thank you!!!
I din m 2 ya 3 kro
@@dewangsingh3376 bhai patience rakho video banane me samy aur mehnat aur bhut preparation lagta h aayegi
@@abcbde8283 team work naam ki ek cheez hove hai
From were u learn java
For Reverse the String Easy Way
String name = "Tony";
for(int i = name.length() - 1 ; i > = 0 ; i - - ) {
System.out.print(name.charAt(i));
}
for reversing the string you can also do this simple method
class FirstClass {
public static void main(String[] args) {
StringBuilder name = new StringBuilder("Hello");
for(int i = name.length()-1;i>=0;i--){
System.out.print(name.charAt(i));
}}}
Smjha ni
Isme replace ka to kuch m h
it is not actually replacing the string your are just printing theme in reverse order.which it is still same in the code you just show character by character in the reverse order on the console without nextline
@@nitinduke this will help
String name="hello";
StringBuilder name2=new StringBuilder("");
int size=name.length()-1;
for(int i=size;i>=0;i--){
name2.append(name.charAt(i));
}
System.out.println(name2);
yeh easy hai but didi ka efficient hai bcoz it has n/2 iterations and this code has n iterations..
@@swarajhegde9059 bhai a length()-1 ka kya matlab hai explain plz
@@shaikasad-yn8he basically when someone does length()-1 tho yeh Samaj lena ki length() function jo output dega usse 1 minus ho rha hai.
For example name="rahul"
Name.length() karne pe rahul name ka length miljayega.. abhi yeh length ko aap apne loop me kaise use karenge wo aap pe depend hai. You can do -1,-2 ,-3 Kitna bhi minus kar sakte ho .use it according to your needs
Instead of front and back character we can simply do reverse for loop and return the reverse string using charAt
public class reverstring {
public static void main(String[] args) {
StringBuilder sb=new StringBuilder("nayra");
System.out.println(sb);
int n=sb.length();
for(int i=n-1;i>=0;i--){
System.out.print(sb.charAt(i));
it will display "aryan"
StringBuilder sb = new StringBuilder("nayra");
sb.reverse();
System.out.println(sb);
14:38 Reverse a String : StringBuilder str = new StringBuilder("APNA COLLEGE");
str.reverse();
System.out.println(str);
OUTPUT: EGELLOC ANPA
Very easy 👍🏻
Took me two days to completely get it, even though it was explained so well. Thank you didi.
Same here
Thought I was the only person learning late
Hates off to @Apna_college . Really need this kind of contant . Thanks a lot.
you are carrer saver giving free valuable content god bless you
real fan of tony stark🤣😂
Madam your way of explaining is awesome
Thankyou so much mam for teaching coding with simple way
thank you APNA COLLEGE. you guys are great.
Thanks didi but pura course complete kigiye hume apke video se bahot help hoti hai
At 17:00 we can also do by using for loop is just reverse direction like initialising by { name.lengthI()-1 to 0 } considering name as out String and just print 🙃🙃🙃🙃
By using loop we can just print a string in reverse ,but can't reverse
@@earthlover449 i think this is what he meant --------> String name="hello";
StringBuilder name2=new StringBuilder("");
int size=name.length()-1;
for(int i=size;i>=0;i--){
name2.append(name.charAt(i));
}
System.out.println(name2);
but jo didi ne sikhaya usme kam iterations use hote hai (n/2)...isme n iterations use hote hai...difference is vast when input is big..aisa lagta hai
@@swarajhegde9059 bhai isme string reverse nehi hua, given string ki value dusri string mein reverse order mein store hua.. given string ka order same hi reh gaya
we can just use sb.reverse(); to reverse the string using StringBuilder.....
SImple code to reverse the String
StringBuilder a = new StringBuilder("aman");
for (int i=a.length()-1;i>=0;i--)
{
System.out.print(a.charAt(i));
}
Best today video about string ❤️
Bhai abhi video aaye 2 min bhi nahi hue. Aur tune 24 min ki video dekhke usko best bhi bol diya.
@@arjun4896 true 😂😂😂
Ye bss promotion k liye h 😂
@@arjun4896 talent bro😂
Reverse for loop se bhi. Ho jayega
for (int i=(sb.length()-1);i>=0;i--){
System.out.print(sb.charAt(i));
function to reverse
static StringBuilder reverse( StringBuilder str){
int n = str.length()-1;
for( int i=0; i
We can also reverse it using two pointer method. Startpoint=0; endPoint =n-1; while loop(start
we wont use pointers in java
Easy way to reverse the string.
for(int i= str.length()-1;i>=0;i--) {
System.out.print(str.charAt(i));
It is just printing , in video mam has done how to actually reverse the main string ... in your loop as soon as the loop ends ... string gets back to its original value
System.out.println("Java is little harder some tricks please");
Reverse string
String s ="Hello";
String rev ="";
for(int i=0; i
StringBuilder sb = new StringBuilder("hello");
System.out.println(sb.reverse());
bohot pyaara explaination
best way to reverse a string is
String reversal= sb.reverse().toString();
System.out.println(reversal);
#Apna College & shradda didi rocks
Very good explanation
SIMPLE WAY TO REVERSE STRING :
String name = "Himanshu";
int m = name.length();
String reverse = "";
for (int i = m - 1; i >= 0; i--) {
reverse += name.charAt(i);
}
System.out.println(reverse);
we can also write in these form:-
import java.util.*;
public class Main{
public static void main (String[] args) {
String b = "";
Scanner s = new Scanner(System.in);
String a = s.next();
for(int i=a.length();i>0;i--){
b+=a.charAt(i-1);
}
System.out.println(b);
}
}
using extra space is not a recommended solution
Well try bro ❤ but It will take extra space and time 🙂
For reversing all characters of a string can also be done by
import java.util.Scanner;
public class javaArray
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String str = sc.next();
StringBuilder sb = new StringBuilder(str);
int len = sb.length();
for(int i=len-1;i>=0;i--)
{
System.out.print(sb.charAt(i)+" ");
}
}
}
Thanks Didi for best content 🙂
I think, Simplest approach to reverse a string is - use reverse loop (for i = str.length()-1 till 0)
that will just print the string in reverse order but the string remains the same
@@saqlainkazi5770 yess but you can add the elements of reverse string loop in a different string using charAt function
reversing the string can be done very simply with a basic logic
public class str4 {
public static void main(String[] args) {
String str = "hello";
int length = str.length();
for(int i = length-1;i>=0;i--){
System.out.print(str.charAt(i));
}
}
}
Keep sharing knowledge shradda
please make videos on aptitude and reasoning for campus placements.it will be helpful for palcements in addition to coding.
yes
I think this will be more easiest way to reverse a String....
public static void main(String[] args) {
String a = "Geet";
for(int i = a.length() - 1 ; i >= 0 ; i --){
System.out.print(a.charAt(i));
}
}
buffer reader ko use karke String rev=anystring,Reverse();
use kar sakte ho
💯🥀 exactly
Why did u did? a. Length() -1
didi aap bohot acche se samjati ho but video thoda lamba kr deti thoda short jo ske tou jaroor krna .thanks
Thank you so much mam ❤️👨💻✅️
4:55 String Builder
Please complete this course as soon as possible....plzzz...
8:28 you can also use a simple method replace instead of setting the char .
I am currently doing a marathon of Java & DSA Course playlist.
How're you learning DSA in java?
@@Aimbolino572 From this channel and other channels.
StringBuilder sb = new StringBuilder("Hello");
sb.reverse(); // becomes "olleH" // simplest answer O(1)
u r great Microsoft Didi ❤❤
Amazing ❤
Finally new video came
I do this question in my style
import java.util.*;
public class learning{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
String name = "Hello";
int i = name.length();
while(i > 0){
i = i -1;
System.out.print(name.charAt(i));
}
}
}
i used this logic 🙄
StringBuilder st=new StringBuilder("helllllo");
for (int i=st.length()-1;i>=0;i--)
{
System.out.println(st.charAt(i));
}
ik its gonna print line by line... but logic seems comfortable
Don't use println instead use print which print it in a single line
For reverce String this short cut method
public static String ReverceString(String str){
for (int i=str.length()-1; i>=0; i--){
System.out.print(str.charAt(i));
}
return str;
}
Only use reverse(); method for reverse string sb.reverse()
just one suggestion in futre videos for any series please use one editor makes so much confusion between vs and intellij shortcuts
Reverse code can be done like: StringBuilder sb = new StringBuilder("Pegoutam");
sb.reverse();
System.out.println(sb);
}
}
We can reverse String without StringBuilder. But we have to make a new String.
import java.util.*;
public class ReverseString {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
String newStr = "";
for(int i=str.length()-1; i>=0; i--){
newStr += str.charAt(i);
}
System.out.println(newStr);
}
}
Sahi hain
bhai a length()-1 ka kya matlab hai explain plz
Also reverse a string by this way:
String palindrome = "Hello World" , reverseStr = "";
int strLength = palindrome.length();
for(int i = strLength-1; i>=0; i--){
reverseStr = reverseStr + palindrome.charAt(i);
}
System.out.println(reverseStr);
Amazing😍. Love from Odisha ❤
Same !
Same...but JEE dropper
ruclips.net/video/awhvPD_cdRw/видео.html
Wow same but in 2023
Aslam o Alikum i am from pakistan apke video se main boht kujh sekh rah ho i love sis agr main sucesses hogya to apse milne zoror aoga, I love sis Allah Apko Khush rakhi or Aman Bhai ko😍🥰
Thanks a lot for creating this video!
Happy teachers day shradhha di😊❤
Thank you so much for providing best content.
public static void main(String args[]) {
StringBuilder str = new StringBuilder("hello");
for (int i = (str.length() - 1); i >= 0; i--) {
System.out.print(str.charAt(i));
}
str.reverse();
System.out.print(str);
}
more easy and simple code in single line
Really thnks alot dii...Really means a lot ...wait for last 2 days ki kab aayagi apki video 😁....but np aap ka kaam bhi simple nhii hai..to explain in such a simplified way...🤗
REVERSE STRING USING STRING BUILDER ::
public class reverseStringBuilder {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder("Hell");
for (int i = 0; i
Didi I used a for loop for whole length for reversing and the method which you gave. the time complexity did not reduce by half. first one was 3s 454 ms and second one was 3s 745 ms
loop alone will not determine time complexity, many common things such as creation of string and initialization of variables were common
Use reverse() of StringBuilder's method for reverse a String
uh... bechara Tony badal ke Pony ho gaya😁
18:30 agar humare pass yahan Aman hota ❤❤😂😂
To reverse string : For loop lenght-1 se lekar 0 tak chalake, charAT(i) ko print karliya tho hojayega
Reverse String
import java.util.Scanner;
public class flip {
public static void main(String[] args) {
String b = "Aman";
for(int i=0; i
Scanner sc = new Scanner(System.in);
String a= sc.nextLine();
String k = " ";
for(int i =0;i
In c++
for(int i = 0; i < s.size()/2; i++) {
swap(s[i],s[s.size() - 1 - i]);
}
public class Main
{
public static void main(String[] args) {
String name = "Manoj";
String rev = " ";
for(int i=name.length()-1;i>=0;i--){
rev = rev+name.charAt(i);
}
System.out.println(rev);
}
}
we can make changes in String without using StringBuilder
Try this:
String a ="Elon";
String name = a.replace("E","M");
System.out.println(name);
Mlon
StringBuilder opposite=new StringBuilder(hello);
opposite.reverse();
System.out.println(opposite);
mam ye bhi to thik hai
jaldi jaldi dalo can't wait
8:50 to anyone facing error during this code which looks like this:
java: incompatible types: java.lang.String cannot be converted to char
then just change the character to 'P' from "P" in the setCharAt function..
I am also new to java and i think apparently java considers " " to be Strings and ' ' to be Character (Char)..
public void reverseString(char[] s) {
int start = 0;
int end = s.length - 1;
while(start < end){
char tmp = s[start];
s[start] = s[end];
s[end] = tmp;
start++;
end--;
}
}
you are brilliant tnk u so much
Great
Upload video of python programming language.
12:05
Meanwhile Marvel : 🤝🫂
we can use this code for revers String ..
public static void main(String[] args) {
StringBuilder sb = new StringBuilder("MOhitDodiya");
StringBuilder sb2 = new StringBuilder("");
for(int i=sb.length()-1;i>=0;i--){
sb2.append(sb.charAt(i));
}
System.out.println(sb2);
}
This logic will only work with the string "hello"
15:09 she already gave us a hint about aman bhaiya 😅
18:31 once again
Are hum ya pe reverse for loop bhi to use kr skte hai.....
String name = "Varun";
for(int i = name.length()-1; i>=0; i--){
System.out.print( name.charAt( i ) ) ;
}
//Output == nuraV
👍👍👍
Thankyou soo much didi