Use the method Arrays.fill(<array>,<value>);` Following an example. import java.util.* int[] myArray = new int[4]; Arrays.fill(myArray, -1); The result of this … More
Tag: java
An algorithm that turns an integer into binary and returns the biggest amount of zeros in the ranges which are between the character “1” of it.
import java.util.*; class Algorithm { public int[] algorithm(int Num) { return Arrays.stream( Integer .toBinaryString(Num) // turn to binary .replaceAll(“(^0+|0+$)”, “”) … More
[Java8] – How to check if all values in an array are equals?
public boolean isAllValuesEquals(int[] Arr ){ if ( Arrays.stream(Arr).distinct().count() == 1 ) { return true; } return false; }
[Java] – How to concatenate two arrays?
public int[] joinArrays(int[] int1, int[] int2) { int[] result = new int[Arr.length]; System.arraycopy( int1, 0, result, 0, int1.length); System.arraycopy( int2, … More
[Tip] – Documentação do #AdoptOpenJDK #OpenJDK #LJC traduzida para português
Documentação dos projetos #AdoptOpenJDK #OpenJDK #LJC traduzida para português: Só acessar o link : https://adoptopenjdk.gitbooks.io/adoptopenjdk-getting-started-kit/content/pt/ Excelente contribuição @allandequeiroz !!!
[Dev] – How to set up “$JAVA_HOME” environment variable on Mac OS X?
For Mac OSX => 10.5 Open the bash_profile file to edit it. $ vim ~/.bash_profile Add into the ~/.bash_profile the … More
[Algorithms] – Find words in reviews of hotels
Problem: Given a set of words and many review of this hotels, you must display the hotels Ids containing in … More
[Algorithms] – The sum of pairs
Problem : Given a set of numbers, you need check if has two numbers in this set that the sum … More
[Algorithms] – Codility Training – BinaryGap
Below is my solution for : https://codility.com/demo/take-sample-test/binary_gap/ public static void main(String[] args) { System.out.println(solution(328)); } public static int solution(int N) … More
[Clojure] – Could I use Java functions with it ?
Yes, it is possible. In this case we use a point before the function to invoke it. Look below : Console … More