Размер видео: 1280 X 720853 X 480640 X 360
Показать панель управления
Автовоспроизведение
Автоповтор
Static varibales cannot be declared inside methods or members of a class
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
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
Remove static for y, you'll get output as 1
static variable can't be declared in funtion scope right?
static variable is not possible, we need to remove either we can keep final
How to do this same using JDK 8 features???
1) convert the array to list 2) Then, list.stream().collect(Collectors.groupingBy(Function.indentity(), Collectors.counting()));
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
Int y is an instance variable, so it can't be static.
Can you please explain sir?I couldn't understand, please explain.
Local variables cannot be static. Static variables can only belong to class level. 👍
Bro plz post python interview questions
Remove the static keyword from the y variable.
Static varibales cannot be declared inside methods or members of a class
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
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
Remove static for y, you'll get output as 1
static variable can't be declared in funtion scope right?
static variable is not possible, we need to remove either we can keep final
How to do this same using JDK 8 features???
1) convert the array to list
2) Then, list.stream().collect(Collectors.groupingBy(Function.indentity(), Collectors.counting()));
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
Int y is an instance variable, so it can't be static.
Can you please explain sir?
I couldn't understand, please explain.
Local variables cannot be static. Static variables can only belong to class level. 👍
Bro plz post python interview questions
Remove the static keyword from the y variable.