Soluții

How to silence Whatsapp calls from unknown numbers

Scammers are now using WhatsApp to call people instead of regular calls. This is because such VoIP calls are not easily identified by using a call-screening app and the user is not notified before picking up the calls.

There wasn’t any feature on WhatsApp to identify spam calls and silence them immediately. Now, WhatsApp is taking this spam call problem seriously and releasing a new feature to silence WhatsApp calls from Unknown numbers. This feature is currently available in the early Beta version of WhatsApp, but it will soon be available to everyone via an update.

[mai mult...]

How to find out WiFi passwords on Android phones using WiFi Key Recovery

We connect to so many WiFi networks on our phone, most of which are password protected to prevent misuse by unauthorized users. As we connect to so many password protected WiFi networks, we may not remember the password for each WiFi network.

If you want to share the WiFi’s password with your friend or if you want to enter it on one of your other devices, you will be forced to ask someone for the password. If you are unable to find out the password yourself, do not worry as your phone remembers the passwords of all the WiFi networks that you have connected to.

While the phone stores all these passwords, you cannot access them yourself as the stored WiFi passwords are not visible to the user. To remedy this, a developer has created an app called WiFi Key Recovery, which works on rooted devices only. This app allows you to see the passwords of all the WiFi devices you have connected to.

[mai mult...]

Replace the spaces of a string with a specific character using Java

  1. public class ReplaceSpace
  2. {
  3.     public static void main(String[] args) {
  4.         String string = “Once in a blue moon”;
  5.         char ch = ‘-‘;
  6.         //Replace space with specific character ch  
  7.         string = string.replace(‘ ‘, ch);
  8.         System.out.println(“String after replacing spaces with given character: “);
  9.         System.out.println(string);
  10.     }
  11. }

Output:

String after replacing spaces with given character: 
Once-in-a-blue-moon
[mai mult...]

Find the most repeated word in a text file with Java

  1. import java.io.BufferedReader;
  2. import java.io.FileReader;
  3. import java.util.ArrayList;
  4. public class MostRepeatedWord {
  5.     public static void main(String[] args) throws Exception {
  6.         String line, word = “”;
  7.         int count = 0, maxCount = 0;
  8.         ArrayList<String> words = new ArrayList<String>();
  9.         //Opens file in read mode  
  10.         FileReader file = new FileReader(“data1.txt “);
  11.         BufferedReader br = new BufferedReader(file);
  12.         //Reads each line  
  13.         while((line = br.readLine()) != null) {
  14.             String string[] = line.toLowerCase().split(“([,.\\s]+) “);
  15.             //Adding all words generated in previous step into words  
  16.             for(String s : string){
  17.                 words.add(s);
  18.             }
  19.         }
  20.         //Determine the most repeated word in a file  
  21.         for(int i = 0; i < words.size(); i++){
  22.             count = 1;
  23.             //Count each word in the file and store it in variable count  
  24.             for(int j = i+1; j < words.size(); j++){
  25.                 if(words.get(i).equals(words.get(j))){
  26.                     count++;
  27.                 }
  28.             }
  29.             //If maxCount is less than count then store value of count in maxCount   
  30.             //and corresponding word to variable word  
  31.             if(count > maxCount){
  32.                 maxCount = count;
  33.                 word = words.get(i);
  34.             }
  35.         }
  36.         System.out.println(“Most repeated word: “ + word);
  37.         br.close();
  38.     }
  39. }

Output:

Most repeated word: word
[mai mult...]

Find the frequency of characters with Java

To accomplish this task, we will maintain an array called freq with same size of the length of the string. Freq will be used to maintain the count of each character present in the string. Now, iterate through the string to compare each character with rest of the string. Increment the count of corresponding element in freq. Finally, iterate through freq to display the frequencies of characters.

For example: Frequency of p in above string is 2.

[mai mult...]

How to Reverse a String in Java

Example 1: Reverse a string word by word using recursion

  1. import java.util.Scanner;
  2. public class ReverseStringExample1
  3. {
  4. public static void main(String[] args)
  5. {
  6. String str;
  7. System.out.println(“Enter a string: “);
  8. Scanner scanner = new Scanner(System.in);
  9. str = scanner.nextLine();
  10. scanner.close();                                //closes the input stream
  11. String reversed = reverseString(str);
  12. System.out.println(“The reversed string is: “ + reversed);
  13. }
  14. public static String reverseString(String s)
  15. {
  16. if (s.isEmpty())                            //checks the string if empty
  17. return s;
  18. return reverseString(s.substring(1)) + s.charAt(0);                     //recursively called function
  19. }
  20. }

Output:

How to Reverse a String in Java Word by Word

[mai mult...]