Hi Naveen Thanks for great work you are doing that helps Automation tester like me a lot. I tried this in another way like below: static void capitalizeString(String str) { String result = ""; String[] ar = str.split("\\s"); for (String s : ar) { char c = Character.toUpperCase(s.charAt(0)); result = result + s.replace(s.charAt(0), c)+" "; } System.out.println(result); }
Thanks @Naveen AutomationLabs for video . What if there is more than one space between two words of String [E.g:- String s="naveen automations labs" ] if we apply this check in for loop we can cover above case also if(word.length()>0){ //logic of converting first letter of word to captial and appending to result string; }
Hi Naveen, Thanks for your continuous videos which is very much helpful to clear the interviews.. kindly explain in a video about when to use static and non static variables in real-time testing
Hi Naveen, thank you for starting on coding questions, Please continue the good work. I solved it without Split and upper case function, making it very performant with String builder and ASCII conversion. Added comments for better reach My solution private static String camelCaseSentence(String str) { if(str.length()== 0 || str == null) return str; StringBuilder sb = new StringBuilder(); sb.append((char)(str.charAt(0) -'a'+'A'));//converting the character with ascii value, first trying to find difference and add it to ascii value of 'A' //and typecast to integer value for (int i = 1; i < str.length(); i++) { if(!(str.charAt(i)==' ')){ sb.append(str.charAt(i)); }else{ //skipping space and convert next char to upper case and increment so that it won't print again sb.append((char)(str.charAt(i+1) -'a'+'A')); // same as above comments. i++; } } return sb.toString(); }
Hi Naveen, Can you please tell me solutions for the question in the below. Split a String but don't split when character repeats.. input s="aHHHbYY"; Out put would be like output:[a, HHH, b, YY] Thanks in advance. Ragards, Kanvitha
Capture string in in char array, iterate through the array. Get ASCI value of each char subtract that with 32 your will get you upper case ASCI value, that's it. Same works the other way round, as A - 65 and a - 97, rest follows.
Hi Naveen Thanks for great work you are doing that helps Automation tester like me a lot. I tried this in another way like below:
static void capitalizeString(String str) {
String result = "";
String[] ar = str.split("\\s");
for (String s : ar) {
char c = Character.toUpperCase(s.charAt(0));
result = result + s.replace(s.charAt(0), c)+" ";
}
System.out.println(result);
}
In this if I want to uppercase only 3character of 2nd word how can we do it?
Great demonstration to make us understand the concept. Thank you!
This is: *The* Naveen Automation Lab guys....
Thanks for covering test cases also, it actually helps to think in those directions also as a beginner in coding.
Thanks Naveen for Covering the Multiple Checks concept in the video 👍😊
Thanks @Naveen AutomationLabs for video .
What if there is more than one space between two words of String [E.g:- String s="naveen automations labs" ]
if we apply this check in for loop we can cover above case also
if(word.length()>0){
//logic of converting first letter of word to captial and appending to result string;
}
it can be easily handled by using \\s+. String words[] = str.split("\\s+");
Hi Naveen, Thanks for your continuous videos which is very much helpful to clear the interviews.. kindly explain in a video about when to use static and non static variables in real-time testing
Please tell how to solve this type of string string s= 2**7***9; output like 2357859
Hi Naveen, thank you for starting on coding questions, Please continue the good work.
I solved it without Split and upper case function, making it very performant with String builder and ASCII conversion.
Added comments for better reach
My solution
private static String camelCaseSentence(String str) {
if(str.length()== 0 || str == null)
return str;
StringBuilder sb = new StringBuilder();
sb.append((char)(str.charAt(0) -'a'+'A'));//converting the character with ascii value, first trying to find difference and add it to ascii value of 'A'
//and typecast to integer value
for (int i = 1; i < str.length(); i++) {
if(!(str.charAt(i)==' ')){
sb.append(str.charAt(i));
}else{ //skipping space and convert next char to upper case and increment so that it won't print again
sb.append((char)(str.charAt(i+1) -'a'+'A')); // same as above comments.
i++;
}
}
return sb.toString();
}
Hi Naveen,
Can you please tell me solutions for the question in the below.
Split a String but don't split when character repeats.. input s="aHHHbYY";
Out put would be like output:[a, HHH, b, YY]
Thanks in advance.
Ragards,
Kanvitha
public static String[] split_string(String str) {
String res ="";
for(int i=0; i
Hii is there any online course is available in your lab..???
Hi Naveen,
Any plans to do series on XCUITest and locators in this framework? Please 😄
What if interviewer asks not to use any String method like toUpperCase()
Capture string in in char array, iterate through the array. Get ASCI value of each char subtract that with 32 your will get you upper case ASCI value, that's it. Same works the other way round, as A - 65 and a - 97, rest follows.
hi @sameer, please see my solution in the comments above. I did more efficiently
@@Savin.Shetty I did the same :)
@@sureshgarine your comment not visible bro.
@@immortalhuman7085 can you please see, i can see it. check with in 1 hr
Sir pls serialization in java, logging, monitoring or apps