java - Get an array slice of 2d array -


i have got 2d string array. how can check slice of it? example row 3, 6th element there

i have tried

  string arr[][] = new string[3][6]   arr[3][4] = "example"   if (arrays.aslist(arr).sublist(3,6).contains("example"))             system.out.print("yes"); 

but doesn't work. works 1d array? also, instead of using contains how can 1 check whether elements null in slice array?

first of all, arrays zero-indexed in java, if declare array first dimension 3, maximum index 2.

second, if want @ slices of third row, should specify index 2 explicitly before converting list.

import java.util.*; public class arraygame {     public static void main(string[] args) {         string arr[][] = new string[3][6];         arr[2][4] = "example";         if (arrays.aslist(arr[2]).sublist(3,6).contains("example"))             system.out.println("yes");         } } 

output:

yes 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -