有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java为什么字符串打印不正确?

我在oracle中创建了一个用户类型

create or replace type my_friend_list 
is
table of 
varchar2(100);

现在我已经编写了一个程序,它有一个如下输出参数:

  PROCEDURE friends_diff_prc
  (
   my_name IN VARCHAR2,
   friend_i   IN my_friend_list ,
   good_friend_o   OUT my_friend_list ,
   best_friend_o   OUT my_friend_list ,
   isSuccess         OUT NUMBER 
  );

我在SQLDeveloper上运行它,它运行正常

它给我列出了我的好朋友和最好的朋友

但是当我通过JAVA类调用它时,它扩展了StoredProcedure

best_friend列表正确,但对于good_friend列表,它正在打印

Ljava.lang.Object;@24342434, 
Ljava.lang.Object;@243a243a,
Ljava.lang.Object;@24402440,
Ljava.lang.Object;@24462446

获取此输出arraylist的java代码如下所示:

List<String> goodfriends = Arrays.asList((String[]) results.get("good_friend_o");
List<String> bestfriends = Arrays.asList((String[]) results.get("best_friend_o");

为什么它不能给好朋友带来正确的结果

提前谢谢


共 (2) 个答案

  1. # 1 楼答案

    试试这个代码。这将打印字符串

    System.out.println("Printing goodfriends");
    for (Object object : goodfriends) {
        Object[] goodfriendsString = (Object[]) object;
        for (Object object2 : objLocationVO) {
        System.out.println(object2);            
         }
    }
    
  2. # 2 楼答案

    以字符串数组的形式获取答案,然后存储在列表字符串中。。不能直接将字符串[]存储到字符串中

    你能发布获取和打印的java代码吗