String key = "I am am learning java java "; String[] words = key.split(" "); HashSet set = new HashSet(); for (String s : words) { if (!set.add(s)) { Log.d("TAG", s); } else { set.add(s); } }
i know Im randomly asking but does anyone know a trick to log back into an Instagram account..? I was stupid forgot the account password. I would appreciate any assistance you can offer me!
@Roger Wilder I really appreciate your reply. I found the site thru google and Im in the hacking process atm. Seems to take quite some time so I will reply here later when my account password hopefully is recovered.
@@mokshanachannel9587 above program is wrong.. If repeated words are not contiguous count will be wrong.. Consider 'am' word is in sentence. Count is 1.. Next word is different.. count is 1 Again 'am' in a sentence.. count++ becomes 2 Next word is different.. count is 1 Again 'am' here count should be 2+1, but the above program returns 1+1 which is incorrect
you can use in this way also it's simple like your previous program bro public class duplicatechar { private static void findDuplicateChar(String string) { char[] ch = string.toCharArray(); HashMap hm = new HashMap(); for (char c : ch) { if (hm.get(c) != null) { hm.put(c, hm.get(c) + 1); } else { hm.put(c, 1); } }
This is all you need. var map = new HashMap(); for(String word : stringArray){ map.merge(word.toLowerCase().replaceAll("[^a-zA-Z]", ""), 1, Integer::sum); } System.out.println(map);
I paused the video and did a dirty log(n)2 version.... String str = "I am am learning java java "; String[] result = str.split(" "); ArrayList list = new ArrayList(); for(int i = 0; i
What if string contains punctuation marks like "I am working on java. Because java is my favourite language." In this case java is not showing as duplicate word. Because there is full stop. Please explain one example with punctuation mark.
Hi Manish, I appreciate ki apne at list video dekha, hashmap ka concept Na jante huea v.. Mein jab Ye Sab sikhta tha, I also had the same feelings and even I was not trying to watch these kind of programs. 😀so you are already doing better than me 👍 So avi Apko pehele hashmap ka concepts sikhna hai.. Then you need to play with these logic's. And before you try solving any kind of logic, make sure you know ki app Kya karne Ja rahe ho.. Then Ye Bahot asan lagega.. I know you can do it once you understand the concept 😊👍
@@SeleniumExpress sir ek last question meine bsc cs last year complete kar loonga lekin abhi tak hamein is baare mein bataya kyun nahi sir mene java ka course bhi kiya tha lekin unhone bhi is baare mein nahi bataya kya ye advanced level ka to nahi hai vaise mein java ke advanced level like jsp servlet , netbeans ide project , like stand alone applicaiton , mysql sever , etc ke baare mein janta hoon kya kisi company mein interview ke liye java ke core concept hi puchhe jaate hai koi netbeans ke graphical question nahi puchta kya please help
Manish,ye sare logical programs interviews mein Bahot importance rakhte hain.. Most of the time the first round is problem solving round where you will get questions like this.. So ap collection framework pe jyada homework kijiye.. Because most of the questions you will get from there.
ArrayList d = new ArrayList(); String sentence = "I am am learning Java Java"; String[] s = sentence.split(" "); for (String a : s) { if(!d.contains(a)) { d.add(a); } } System.out.println(d);
String s="this is java program" I want to find the index of 'is' in string. But when I find using indexOf("is") it return the index of first is which is in 'this' word. Can u tell me how to find that....
Hi Harshit.Hope below code will help.Revert back for any further query. static void check() { ArrayList list = new ArrayList(); for(int i = 0 ; i= 0 && tempInt = 70 && tempInt
map.put(str1, map.get(str1) + 1); } this line is not working. error message - The operator + is undefined for the argument type(s) Object, int can you please what I can do here? Thanks in Advance.
you cannot get such a error:- check this program package myapp; import java.util.HashMap; import java.util.Map; public class DuplicateString { public static void main(String[] args) { String str = "I am am learning java java"; DuplicateString obj = new DuplicateString(); obj.calculateDuplicateString(str); }
@@krishnasingh9111 package myapp; import java.util.HashMap; import java.util.Map; public class DuplicateString { public static void main(String[] args) { String str = "I am am learning java java"; DuplicateString obj = new DuplicateString(); obj.calculateDuplicateString(str); }
String key = "I am am learning java java "; String[] words = key.split(" "); for (int i = 0; i < words.length; i++) { for (int j = i + 1; j < words.length; j++) { if (words[i].equalsIgnoreCase(words[j])) { Log.d("TAG", words[i]); } } }
String key = "I am am learning java java ";
String[] words = key.split(" ");
HashSet set = new HashSet();
for (String s : words) {
if (!set.add(s)) {
Log.d("TAG", s);
} else {
set.add(s);
}
}
I am an experienced java developer. Please upload more videos. It will be helpful for interviews. Thanks for this video
I would say go with java 8 stream, it would be only one line of code!
10:20 (Line 15) if(hm.get(tempString) != null)
I think it checks 'value', not 'key'.
You explain us in a very practical manner, easy to understand...
I am impressed of your video and also I am first time commenting in any video.
Great example! Thanks for sharing. Keep up the great work!
i know Im randomly asking but does anyone know a trick to log back into an Instagram account..?
I was stupid forgot the account password. I would appreciate any assistance you can offer me!
@Vicente Dominic Instablaster =)
@Roger Wilder I really appreciate your reply. I found the site thru google and Im in the hacking process atm.
Seems to take quite some time so I will reply here later when my account password hopefully is recovered.
@Roger Wilder it did the trick and I now got access to my account again. Im so happy!
Thanks so much you saved my ass!
@Vicente Dominic You are welcome =)
Concise code
String str ="I am am learning learning learning Java Java Java";
String []st=str.split(" ");
int count=0;
Map stor = new HashMap();
for(String s:st)
{
if(stor.containsKey(s))
{
count++;
stor.put(s,count);
}
else
{
count=1;
stor.put(s,count);
}
}
Contains shouldn't be used which leads to performance issue
What if string has"i am learning Java and Java"
@@mokshanachannel9587 above program is wrong..
If repeated words are not contiguous count will be wrong..
Consider 'am' word is in sentence.
Count is 1..
Next word is different.. count is 1
Again 'am' in a sentence.. count++ becomes 2
Next word is different.. count is 1
Again 'am' here count should be 2+1, but the above program returns 1+1 which is incorrect
Thanks for this video 🙏
Starting music is same which Guru Maan Sir is using.
i love the way you explain the things
Vdo👌
Somewhere i have feeling that you made problem more complex while solving
good one
Video ke starting me jo Audio hai. Kya nam hai uska???
Nice explanation
you can use in this way also it's simple like your previous program bro
public class duplicatechar {
private static void findDuplicateChar(String string) {
char[] ch = string.toCharArray();
HashMap hm = new HashMap();
for (char c : ch) {
if (hm.get(c) != null) {
hm.put(c, hm.get(c) + 1);
} else {
hm.put(c, 1);
}
}
Awesome explanation brother keep rocking 🎸🎶🎶
Thank you. 🏆🏆🏆
Please try- Find occurrences of given substring in given string with optimized code.
Great explanation!
good boss
Namaste guru
static void findDuplicate(String text) {
String[] strAr = text.split(" ");
Set set = new HashSet();
Map map = new HashMap();
for(int i=0;i
Great explaining.Keep it up...
How to remove duplicate in a string (using java) can you please make a video for that ...Thanks
Super bro,
Awesome explanation sir .... representation is suuuuuper....
This is all you need.
var map = new HashMap();
for(String word : stringArray){
map.merge(word.toLowerCase().replaceAll("[^a-zA-Z]", ""), 1, Integer::sum);
}
System.out.println(map);
thanks brother, you are teaching exactly the way i want. :)
good explanation , whats happens in case of Variable? if there is same variable in both parent and child class then which one gets called ?
Really worth videos thanks a lot .. could you please prepare one video of java 8 features please
Thanks, Suresh. Sure will prepare one soon.
Thanks for replying
Superb bro...keep rocking for ur explanation bro...
Nicely explained....
Just beautiful ❤️. make more videos man
I paused the video and did a dirty log(n)2 version....
String str = "I am am learning java java ";
String[] result = str.split(" ");
ArrayList list = new ArrayList();
for(int i = 0; i
Good code but what in case we also want the count of the repeated words?
Hi thank you for the video. Can you also write the unit test for this example ?
Very nice tutorial
Thanks, Vidhit.😊
Thanks sir! Great explanation
super explanation bro
Awwsome thnks
Cool. But what if we want out the words in the same order as they appear in the initial sentence?
You can use containskey method instead of get
Why you have used iterator you can use for each loop for iterating through values
Can use entrySet() which returns Entry Interface.
Thank you 😊😘❤️
Very nice friend, but you can use the computer to work as a blackbord, so we can see your writings better, and the sound is better too :-)
Thank you, Vinicius.. I will keep your suggestions in mind. Thank you for taking time and writing a feedback.
Have a nice time 😊
What if string contains punctuation marks like
"I am working on java. Because java is my favourite language."
In this case java is not showing as duplicate word. Because there is full stop. Please explain one example with punctuation mark.
First split based on punctuation using regex and one more for loop...that will work
Instead of hashmap u should've used set cuz it doesn't store duplicate values...
bhai itni coding to kabhi yaad nahi hogi kya golmaal hai
hasmap to java mein mene abhi padha bhi nahi hai
dara diya apne mujhe
Hi Manish,
I appreciate ki apne at list video dekha, hashmap ka concept Na jante huea v.. Mein jab Ye Sab sikhta tha, I also had the same feelings and even I was not trying to watch these kind of programs. 😀so you are already doing better than me 👍
So avi Apko pehele hashmap ka concepts sikhna hai.. Then you need to play with these logic's.
And before you try solving any kind of logic, make sure you know ki app Kya karne Ja rahe ho.. Then Ye Bahot asan lagega..
I know you can do it once you understand the concept 😊👍
@@SeleniumExpress sir ek last question meine bsc cs last year complete kar loonga lekin abhi tak hamein is baare mein bataya kyun nahi
sir mene java ka course bhi kiya tha lekin unhone bhi is baare mein nahi bataya
kya ye advanced level ka to nahi hai vaise mein java ke advanced level like jsp servlet , netbeans ide project , like stand alone applicaiton , mysql sever , etc ke baare mein janta hoon
kya kisi company mein interview ke liye java ke core concept hi puchhe jaate hai koi netbeans ke graphical question nahi puchta kya
please help
Manish,ye sare logical programs interviews mein Bahot importance rakhte hain.. Most of the time the first round is problem solving round where you will get questions like this..
So ap collection framework pe jyada homework kijiye.. Because most of the questions you will get from there.
Why not used hm.contains(tempString) in if condition at line 15
Make videos on jdbc and core java
print duplicate characters in a string (using java) can you please make a video for that also how to remove duplicate string or char ..thank you
if u want a video cantact me in whatsapp +917358252858
@@damodaranm3044 How to remove duplicate in a string (using java) can you please make a video for that ...Thanks using same code
Will it be easier if lambda was applied?
what about spaces, if we have spaces how to remove that spaces while counting
You can use replace function to replace space with no-space Replace(" ","") like this
Do you know how to create videos using our own laptop.. which software can be used without any charges?
nice but very lengthy code
If I want the input through excel and display the duplicates. How to do?
"right?"
Bro can know to make the table format (match type questionsin strings
concurrentHaspMap would not be better? where you are iterating, you can remove all the elements having value 1.
Frd super videos, but I want how to remove duplicates in string
ArrayList d = new ArrayList();
String sentence = "I am am learning Java Java";
String[] s = sentence.split(" ");
for (String a : s) {
if(!d.contains(a))
{
d.add(a);
}
}
System.out.println(d);
i wonder why do u use hashmap
any datastucture can do this
String str = "i am am learning java java";
String[] arr = str.split(" ");
ArrayList al = new ArrayList();
for(int i = 0 ; i < arr.length ; i++ ) {
if(!al.contains(arr[i])) {
al.add(arr[i]);
}
else {
System.out.println(arr[i]);
}
}
}
public static void countDuplicateWord(String string){
String sourceArr[] = string.split(" ");
Map stringIntegerMapMap = new HashMap();
for (String str : sourceArr) {
Integer previousValue = stringIntegerMapMap.put(str, 1);
if (previousValue != null) {
stringIntegerMapMap.put(str, previousValue + 1);
}
}
System.out.println(stringIntegerMapMap);
}
public static void countDuplicateCharacter(String word){
Map characterIntegerMap = new HashMap();
for (int i = 0; i < word.length(); i++) {
Integer previousValue = characterIntegerMap.put(word.charAt(i), 1);
if (previousValue != null) {
characterIntegerMap.put(word.charAt(i), previousValue + 1);
}
}
System.out.println(characterIntegerMap);
}
String s="this is java program"
I want to find the index of 'is' in string. But when I find using indexOf("is") it return the index of first is which is in 'this' word. Can u tell me how to find that....
In your case, you can use lastIndexOf("is")
use " is" give some gap i think
why you did not use SET for find duplicate values.
Because we needed key and values pair so here he's using map
Bro make a method in java that iterate prime number between 0-200 and return the prime number between 0-20 and 70-90
Hi Harshit.Hope below code will help.Revert back for any further query.
static void check()
{
ArrayList list = new ArrayList();
for(int i = 0 ; i= 0 && tempInt = 70 && tempInt
or u can simply write like this..
for (Iterator iterator = a.iterator(); iterator.hasNext();)
{
Integer obj = (Integer) iterator.next();
if (obj>=2 && obj=70 && obj
I thought I opened Guruman fitness video 😂
Can anyone explain hm.put(tempting,him.get(tempstring)+1)
hi plz upload some video
{
map.put(str1, map.get(str1) + 1);
}
this line is not working.
error message - The operator + is undefined for the argument type(s) Object, int
can you please what I can do here?
Thanks in Advance.
I am getting same error if resolve please post your solution ..
you cannot get such a error:-
check this program
package myapp;
import java.util.HashMap;
import java.util.Map;
public class DuplicateString {
public static void main(String[] args) {
String str = "I am am learning java java";
DuplicateString obj = new DuplicateString();
obj.calculateDuplicateString(str);
}
public void calculateDuplicateString(String str) {
Map string_literals_map = new HashMap();
String [] str_array = str.split(" ");
for (String str_literals : str_array) {
//System.out.println(str_literals);
if(string_literals_map.containsKey(str_literals)) {
string_literals_map.put(str_literals, string_literals_map.get(str_literals) + 1);
}
else {
string_literals_map.put(str_literals, 1);
}
}
System.out.println(string_literals_map);
}
}
@@krishnasingh9111
package myapp;
import java.util.HashMap;
import java.util.Map;
public class DuplicateString {
public static void main(String[] args) {
String str = "I am am learning java java";
DuplicateString obj = new DuplicateString();
obj.calculateDuplicateString(str);
}
public void calculateDuplicateString(String str) {
Map string_literals_map = new HashMap();
String [] str_array = str.split(" ");
for (String str_literals : str_array) {
//System.out.println(str_literals);
if(string_literals_map.containsKey(str_literals)) {
string_literals_map.put(str_literals, string_literals_map.get(str_literals) + 1);
}
else {
string_literals_map.put(str_literals, 1);
}
}
System.out.println(string_literals_map);
}
}
why we used iterator there , am not getting it ?
to iterate ..its just like for loop
Annoying slang... sorry... unable to graspe the content coz of this slang.... looks artificial....
String key = "I am am learning java java ";
String[] words = key.split(" ");
for (int i = 0; i < words.length; i++) {
for (int j = i + 1; j < words.length; j++) {
if (words[i].equalsIgnoreCase(words[j])) {
Log.d("TAG", words[i]);
}
}
}
But in this case time complexity is O(n^2).
U copied background music from gurumann
how to sovle xml parsing error in spring
You are creating complex coding...when beginners will watch your coding then he will suicide...
😂😂😂
No clarity
String str1 = "I am am walking walking java java java java";
String[] strings = str1.split(" ");
Map myMap = new HashMap();
for(String x : strings){
if(!myMap.containsKey(x)){
myMap.put(x,1);
} else{
myMap.put(x,myMap.get(x) + 1);
}
}
Set keys = myMap.keySet();
for(String key: keys){
if(myMap.get(key)> 1){
System.out.println(key);
}
}