JAVA関連のことを調べてみた2021年09月28日

JAVA関連のことを調べてみた2021年09月28日

Java Word文書からPDFに変換

Spire.Doc for Javaを利用することで、Wordファイルから、ただ数秒で様々なファイルに変換できます。これこそが、Javaでプログラミングを行う開発者にとって、とても使いやすいライブラリじゃないでしょうか。さあ、今回は、Word文書からPDFに変換する方法を紹介していきましょう!簡単なので、もしお役に立てば嬉しいと思います。

Spire.Doc for Javaとは?

Spire. Doc for Javaは、E-iceblue社が開発され、開発者が JavaプラットホームでWordのドキュメントを迅速か

[100%] CountSemiprimes

_Lesson11_
## [Sieve of Eratosthenes](https://app.codility.com/programmers/lessons/11-sieve_of_eratosthenes/)

[Open reading material (PDF)](https://codility.com/media/train/9-Sieve.pdf)

> _Medium_
> ### [CountSemiprimes](https://app.codility.com/programmers/lessons/11-sieve_of_eratosthenes/count_semiprimes/)
> Count the semiprime numbers in the given range [a..b]

#### Task description

A prime is a positive integer X that has exactly two distinct divisors: 1 and X. The first few prime integer

[100%] CountNonDivisible

_Lesson11_
## [Sieve of Eratosthenes](https://app.codility.com/programmers/lessons/11-sieve_of_eratosthenes/)

[Open reading material (PDF)](https://codility.com/media/train/9-Sieve.pdf)

> _Medium_
> ### [CountNonDivisible](https://app.codility.com/programmers/lessons/11-sieve_of_eratosthenes/count_non_divisible/)
> Calculate the number of elements of an array that are not divisors of each element.

#### Task description

You are given an array A consisting of N integers.

For each number A[i]

[100%] Peaks

_Lesson10_
## [Prime and composite numbers](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/)

[Open reading material (PDF)](https://codility.com/media/train/8-PrimeNumbers.pdf)

> _Medium_
> ### [Peaks](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/peaks/)
> Divide an array into the maximum number of same-sized blocks, each of which should contain an index P such that A[P – 1] < A[P] > A[P + 1].

### Task description

A non-empty array A

[100%] Flags

_Lesson10_
## [Prime and composite numbers](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/)

[Open reading material (PDF)](https://codility.com/media/train/8-PrimeNumbers.pdf)

> _Medium_
> ### [Flags](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/flags/)
> Find the maximum number of flags that can be set on mountain peaks.

#### Task description

A non-empty array A consisting of N integers is given.

A peak is an array element which i

[100%] MinPerimeterRectangle

_Lesson10_
## [Prime and composite numbers](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/)

[Open reading material (PDF)](https://codility.com/media/train/8-PrimeNumbers.pdf)

> _Easy_
> ### [MinPerimeterRectangle](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/min_perimeter_rectangle/)
> Find the minimal perimeter of any rectangle whose area equals N.

#### Task description

An integer N is given, representing the area of some rectang

[100%] CountFactors

_Lesson10_
## [Prime and composite numbers](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/)

[Open reading material (PDF)](https://codility.com/media/train/8-PrimeNumbers.pdf)

> _Easy_
> ### [CountFactors](https://app.codility.com/programmers/lessons/10-prime_and_composite_numbers/count_factors/)
> Count factors of given number n.

#### Task description

A positive integer D is a factor of a positive integer N if there exists an integer M such that N = D * M.

For

[100%] MaxDoubleSliceSum

_Lesson9_
## [Maximum slice problem](https://app.codility.com/programmers/lessons/9-maximum_slice_problem/)

[Open reading material (PDF)](https://codility.com/media/train/7-MaxSlice.pdf)

> _Medium_
> ### [MaxDoubleSliceSum](https://app.codility.com/programmers/lessons/9-maximum_slice_problem/max_double_slice_sum/)
> Find the maximal sum of any double slice.

#### Task description

A non-empty array A consisting of N integers is given.

A triplet (X, Y, Z), such that 0 ≤ X < Y < Z < N, is calle

[100%] MaxSliceSum

_Lesson9_
## [Maximum slice problem](https://app.codility.com/programmers/lessons/9-maximum_slice_problem/)

[Open reading material (PDF)](https://codility.com/media/train/7-MaxSlice.pdf)

> _Easy_
> ### [MaxSliceSum](https://app.codility.com/programmers/lessons/9-maximum_slice_problem/max_slice_sum/)
> Find a maximum sum of a compact subsequence of array elements.

#### Task description

A non-empty array A consisting of N integers is given. A pair of integers (P, Q), such that 0 ≤ P ≤ Q < N, i

[100%] MaxProfit

_Lesson9_
## [Maximum slice problem](https://app.codility.com/programmers/lessons/9-maximum_slice_problem/)

[Open reading material (PDF)](https://codility.com/media/train/7-MaxSlice.pdf)

> _Easy_
> ### [MaxProfit](https://app.codility.com/programmers/lessons/9-maximum_slice_problem/max_profit/)
> Given a log of stock prices compute the maximum possible earning.

#### Task description

An array A consisting of N integers is given. It contains daily prices of a stock share for a period of N cons

[100%] EquiLeader

_Lesson8_
## [Leader](https://app.codility.com/programmers/lessons/8-leader/)

[Open reading material (PDF)](https://codility.com/media/train/6-Leader.pdf)

> _Easy_
> ### [EquiLeader](https://app.codility.com/programmers/lessons/8-leader/equi_leader/)
> Find the index S such that the leaders of the sequences A[0], A[1], …, A[S] and A[S + 1], A[S + 2], …, A[N – 1] are the same.

#### Task description

A non-empty array A consisting of N integers is given.

The leader of this array is the val

[100%] Dominator

_Lesson8_
## [Leader](https://app.codility.com/programmers/lessons/8-leader/)

[Open reading material (PDF)](https://codility.com/media/train/6-Leader.pdf)

> _Easy_
> ### [Dominator](https://app.codility.com/programmers/lessons/8-leader/dominator/)
> Find an index of an array such that its value occurs at more than half of indices in the array.

#### Task description
***
An array A consisting of N integers is given. The dominator of array A is the value that occurs in more than half of the elem

[100%] StoneWall

_Lesson7_
## [Stacks and Queues](https://app.codility.com/programmers/lessons/7-stacks_and_queues/)

[Open reading material (PDF)](https://codility.com/media/train/5-Stacks.pdf)

> _Easy_
> ### [StoneWall](https://app.codility.com/programmers/lessons/7-stacks_and_queues/stone_wall/)
> Cover “Manhattan skyline” using the minimum number of rectangles.

#### Task description
***

You are going to build a stone wall. The wall should be straight and N meters long, and its thickness should be constan

[100%] Nesting

_Lesson7_
## [Stacks and Queues](https://app.codility.com/programmers/lessons/7-stacks_and_queues/)

[Open reading material (PDF)](https://codility.com/media/train/5-Stacks.pdf)

> _Easy_
> ### [Nesting](https://app.codility.com/programmers/lessons/7-stacks_and_queues/nesting/)
> Determine whether a given string of parentheses (single type) is properly nested.

#### Task description
***
A string S consisting of N characters is called properly nested if:

* S is empty;
* S has the form “(U)” wh

[100%] Fish

_Lesson7_

## [Stacks and Queues](https://app.codility.com/programmers/lessons/7-stacks_and_queues/)

[Open reading material (PDF)](https://codility.com/media/train/5-Stacks.pdf)

> _Easy_
> ### [Fish](https://app.codility.com/programmers/lessons/7-stacks_and_queues/fish/)
> N voracious fish are moving along a river. Calculate how many fish are alive.

#### Task description
***
You are given two non-empty arrays A and B consisting of N integers. Arrays A and B represent N voracious fish in a ri

[100%] Brackets

_Lesson7_

## [Stacks and Queues](https://app.codility.com/programmers/lessons/7-stacks_and_queues/)

[Open reading material (PDF)](https://codility.com/media/train/5-Stacks.pdf)

> _Easy_
> ### [Brackets](https://app.codility.com/programmers/lessons/7-stacks_and_queues/brackets/)
> Determine whether a given string of parentheses (multiple types) is properly nested.

#### Task description
***
A string S consisting of N characters is considered to be properly nested if any of the following condit

[100%] Triangle

_Lesson6_
## [Sorting](https://app.codility.com/programmers/lessons/6-sorting/)

[Open reading material (PDF)](https://codility.com/media/train/4-Sorting.pdf)

> _Easy_
> ### [Triangle](https://app.codility.com/programmers/lessons/6-sorting/triangle/)
> Determine whether a triangle can be built from a given set of edges.

#### Task description
***
An array A consisting of N integers is given. A triplet (P, Q, R) is triangular if 0 ≤ P < Q < R < N and: * A[P] + A[Q] > A[R],
* A[Q] + A[R] > A[P],

[100%] Number of discIntersections

> _Medium_
> ### [NumberOfDiscIntersections](https://app.codility.com/programmers/lessons/6-sorting/number_of_disc_intersections/)
> Compute the number of intersections in a sequence of discs.

#### Task description
***
We draw N discs on a plane. The discs are numbered from 0 to N − 1. An array A of N non-negative integers, specifying the radiuses of the discs, is given. The J-th disc is drawn with its center at (J, 0) and radius A[J].

We say that the J-th disc and K-th disc intersect if J ≠ K

初心者が1から始めるJava開発〜目次編〜

探すのがめんどくさくなってきそうなので、
そろそろまとめ記事にしとこうと思って。。。。

社内の一部の若手開発者向けに勉強会をした時の記事です。

6回目以降はやってません(今は6回目までしかない)

[初心者が1から始めるJava開発-Vol.1- eclipseセットアップ編](https://qiita.com/soepy/items/898b89284be3c228a951)

[初心者が1から始めるJava開発-Vol.2- Javaプロジェクト作成編](https://qiita.com/soepy/items/f8e78d6a29c164abb321)

[初心者が1から始めるJava開発-Vol.3- クラス、メソッド編](https://qiita.com/soepy/items/135cd35ba678f2b2a246)

[初心者が1から始めるJava開発-Vol.4- 条件分岐編](https://qiita.com/soepy/items/cfaa9927042bdd36fcf7)

[初心者が1から始めるJava開発-Vol.5- 繰り返し編](http

mockitoのverifyでany()と引数指定を混ぜて使いたい

## 詰まった事象

“`java
verify(service).hogehoge(any(), any()); // OK
verify(service).hogehoge(“fuga” , “piyo”); // OK
verify(service).hogehoge(any(), “piyo”); // NG
“`

## 解決策

Matcherを使いましょう。

“`java
verify(service).hogehoge(any(), eq(“piyo”));
“`

実はエラーログに親切に書いてありました。

“`
This exception may occur if matchers are combined with raw values:
//incorrect:
someMethod(anyObject(), “raw String”);
When using matchers, all arguments have to be provided by matchers.
For example:
//correct: