[Solved] How to find the maximum’s index?

You have declared: public double MaxKiv() { So yes, obviously this gives you a double. To get an int instead, simply change the declaration to return an int: public int MaxKiv() { The value you are returning, index, is already declared an int, so this should be enough fix your issue. 0 solved How to … Read more

[Solved] What’s different between a single precision and double precision floating values? [duplicate]

In C, double has at least as much precision as, and usually more than, float, and has at least the exponent range of, and usually more than, float. The C standard only requires that double be able to represent all the values of float: “The set of values of the type float is a subset … Read more

[Solved] Java Error: Too many open files [duplicate]

The most likely explanation is that you have a bug in your Java application that is causing it to leak file open files. The way to avoid the problem is to write your code so that file handles are always closed; e.g. // Using the ‘try with resource’ construct try (Reader r = new FileReader(…)) … Read more

[Solved] java characters in a string

This should do it. What it does is that it gets a string to look at, gets a character to look at, iterates through the string looking for matches, counts the number of matches, and then returns the information. There are more elegant ways to do this (for example, using a regex matcher would also … Read more

[Solved] How can I change one function value in a boolean-valued java Function?

Maybe what you actually want is to use a Predicate? Predicate<Integer> crazyFunction = x -> false; for (Integer thisInteger : listOfIntegers) { crazyFunction = crazyFunction.or(Predicate.isEqual(thisInteger)); } // Is a given integer one of our integers? boolean isGoodInteger = crazyFunction.apply(42); 2 solved How can I change one function value in a boolean-valued java Function?

[Solved] How to write a function named isMeera that returns 1 if its array argument is a Meera array. Otherwise, it returns 0 [closed]

Finally it works successfully ! public static int isMeera(int [] a){ boolean hasOdd = false; int firstEven = 0; int lastEven = 0; boolean firstCountEnd = false; boolean lastCountEnd = false; for(int i = 0; i<a.length; i++){ if (a[i]%2 == 1) { hasOdd = true; break; } } if (!hasOdd) return 0; for (int j … Read more

[Solved] Java Expect “{” error dont understand

Remove .java in source code. change below line public class Bister.java { like this public class Bister { Your code will be like import java.util.Scanner; public class Bister { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print(“Input first number: “); int num1 = in.nextInt(); System.out.print(“Input second number: “); int num2 = … Read more

[Solved] how do you count the number of digits in an int?

You can use split to find all the matches String number = “128”; String digit = “2”; // expensive but simple. int matches = number.split(digit).length – 1; Say you want to use a loop and something like contains. // no objects char digit=”2″; int count = 0; for (int pos = number.indexOf(digit); pos >= 0; … Read more

[Solved] Frequency distribution of words [duplicate]

Sample code is something like this: String str1 = “java;python;javascript;programming;Hello;World;Hello”; String str2 = “java;python;javascript;programming;Hello;World;Hello”; List<String> list = new ArrayList<String>(); list.addAll(Arrays.asList(str1.split(“;”))); list.addAll(Arrays.asList(str2.split(“;”))); for (String word : list) System.out.println(word + ” –> ” + Collections.frequency(list,word)); 1 solved Frequency distribution of words [duplicate]