Find Count Of Each Element from Array | Java Interview Questions and Answers

  Рет қаралды 13,635

CloudTech

CloudTech

Күн бұрын

Пікірлер: 14
@revathir1995
@revathir1995 2 жыл бұрын
Static varibales cannot be declared inside methods or members of a class
@satishbhutawale4226
@satishbhutawale4226 8 ай бұрын
package com.method; public class FrequencyOfElements { public static void main(String[] args) { int[] arr= {10,20,30,10,30,40,50,50,50,60}; int[] count=new int[256]; for(int i=0;i
@rads1436
@rads1436 6 ай бұрын
may i know y the count of 10 is again printing as 2 so we neeed to set the value to -1 if the number is going to repeat again
@shivask1751
@shivask1751 2 жыл бұрын
Remove static for y, you'll get output as 1
@sathiskumarp
@sathiskumarp 2 жыл бұрын
static variable is not possible, we need to remove either we can keep final
@nanisai8264
@nanisai8264 2 жыл бұрын
Int y is an instance variable, so it can't be static.
@pinkubose2994
@pinkubose2994 2 жыл бұрын
Can you please explain sir? I couldn't understand, please explain.
@cloudtech5260
@cloudtech5260 2 жыл бұрын
Local variables cannot be static. Static variables can only belong to class level. 👍
@rpstudio9298
@rpstudio9298 2 жыл бұрын
How to do this same using JDK 8 features???
@varanasivamsikrishna7795
@varanasivamsikrishna7795 2 жыл бұрын
1) convert the array to list 2) Then, list.stream().collect(Collectors.groupingBy(Function.indentity(), Collectors.counting()));
@letsexplorewithsoumyaranja2045
@letsexplorewithsoumyaranja2045 2 жыл бұрын
Remove the static keyword from the y variable.
@bheemarayaa9507
@bheemarayaa9507 2 жыл бұрын
static variable can't be declared in funtion scope right?
@rajuveerla9352
@rajuveerla9352 2 жыл бұрын
Bro plz post python interview questions
@ashishsingh8222
@ashishsingh8222 4 ай бұрын
Map numsInMap = Arrays.stream(nums).boxed() .collect(Collectors.groupingBy(x -> x, Collectors.counting())); numsInMap.entrySet().forEach(x -> System.out.println(x.getKey() + " -> " + x.getValue())); for java 8
Reverse Sentence By Words - Logic Building Practice
6:49
CloudTech
Рет қаралды 23 М.
Creative Justice at the Checkout: Bananas and Eggs Showdown #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 33 МЛН
Smart Sigma Kid #funny #sigma
00:33
CRAZY GREAPA
Рет қаралды 31 МЛН
Farmer narrowly escapes tiger attack
00:20
CTV News
Рет қаралды 13 МЛН
Capgemini Java Coding Interview | Mock Java Coding Interview
10:31
Java 8, Streams, Concurrent Hashmap | Infosys Java Interview
17:34
Creative Justice at the Checkout: Bananas and Eggs Showdown #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 33 МЛН