Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java char[]返回代码中的类型不接受char[i][]值 public char[]Cache\u 1(int-word\u地址,int-Cache\u集,int-ls,char[]s1) { 字符缓存_1[][]=新字符[32][4]; 字符s0[]=新字符[32]; 互联网络ic=新互联网络(); 如果(ls==“0”){ 如果((cache_1[cache_set][0])=='1'){//检查有效位并传输内容 //如果有效位为高 对于(int i=0;i_Java - Fatal编程技术网

Java char[]返回代码中的类型不接受char[i][]值 public char[]Cache\u 1(int-word\u地址,int-Cache\u集,int-ls,char[]s1) { 字符缓存_1[][]=新字符[32][4]; 字符s0[]=新字符[32]; 互联网络ic=新互联网络(); 如果(ls==“0”){ 如果((cache_1[cache_set][0])=='1'){//检查有效位并传输内容 //如果有效位为高 对于(int i=0;i

Java char[]返回代码中的类型不接受char[i][]值 public char[]Cache\u 1(int-word\u地址,int-Cache\u集,int-ls,char[]s1) { 字符缓存_1[][]=新字符[32][4]; 字符s0[]=新字符[32]; 互联网络ic=新互联网络(); 如果(ls==“0”){ 如果((cache_1[cache_set][0])=='1'){//检查有效位并传输内容 //如果有效位为高 对于(int i=0;i,java,Java,您应该返回cache\u 1[cache\u set],而不是cache\u 1[cache\u set][]您将返回类型定义为 public char[] Cache_1(int word_address,int cache_set,int ls,char[] s1) { char cache_1[][] = new char[32][4]; char s0[] = new char[32]; InterConnectionNetwork ic = new Inte

您应该返回
cache\u 1[cache\u set]
,而不是
cache\u 1[cache\u set][]

您将返回类型定义为

public char[] Cache_1(int word_address,int cache_set,int ls,char[] s1)
{
    char cache_1[][] = new char[32][4];

    char s0[] = new char[32];
    InterConnectionNetwork ic =  new InterConnectionNetwork();

    if(ls == '0') {
        if((cache_1[cache_set][0]) == '1') { // Check Valid Bit and transfer content 
                                             // if valid bit is high
            for(int i=0;i<32;i++) {          // Load
               s0[i] = cache_1[cache_set][i];
            }
        } else {                             // Valid bit low
          s0 = ic.determinenode(word_address);                    
        }            
        return s0;
    } else {        
        if((cache_1[cache_set][0]) == '1') {
            for(int i=0;i<32;i++) {
                cache_1[cache_set][i] = s0[i];
            }
        } else
            cache_1[cache_set][] = ic.determinenode(word_address);  //returns char[]    
        return (cache_1[cache_set][]);       //Problem here
    }          
}
这意味着字符数组(线性)

你回来了

 char[]
如果写得正确,则返回的是
char
而不是
char[]
你必须改变其中任何一个

cache_1[cache_set][] //should give multiple error and one for not giving index inside the second [?]