Compiled Java class not working in MATLAB

조회 수: 2 (최근 30일)
Ilya Tyuryukanov
Ilya Tyuryukanov 2018년 10월 23일
답변: Mohan Feng 2018년 10월 25일
I've compiled the following Java code as the comment header suggests: https://algs4.cs.princeton.edu/24pq/IndexMinPQ.java.html (The StdOut class is under this link: https://introcs.cs.princeton.edu/java/stdlib/StdOut.java.html)
However, this indexed priority queue that I really need (and possibly not only me...) returns errors in MATLAB. Namely, object construction seems to work fine:
q = IndexMinPQ(222) // works
but calling object methods fails:
q.insert(int32(3), 22) // fails
I've tried to comply with the announced MATLAB-Java type mappings, but still get this error:
No method 'insert' with matching signature found for class 'IndexMinPQ'.

채택된 답변

Mohan Feng
Mohan Feng 2018년 10월 25일
The second argument of function "insert" is java.lang.Comparable. My observation for this case is that you might need to first create a Java Integer instance or Java String instance by JAVA constructor in MATLAB and pass the JAVA instance directly into the "insert" function instead of letting MATLAB to cast for you. For example,
r = IndexMinPQ(220);
i = java.lang.Integer(22);
r.insert(3, i);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call Java from MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by