+ 1
Guys this fxn mst accept a char array, a 0 based start position and a length. It shud return a char array containn length chars.
public class Program { public static void main (String []args ){ char[] arr={"a","b","c"}; int s =0 ; int l = 4; char[]sub=a3(arr,s,l); System.out.println (sub); } public static char [] a3(char[]a,int start,int length){ if (length<0||start<0||start+length-1>=a.length) { return null ; } char[]sub=new char [length ]; int i=start; i++; for(j=0;j<length;j++){ sub [j] = a[i]; } } return sub ; }
1 Odpowiedź
+ 1
the char array shud start with the start character of the input array. what am I missing here? its saying"missing ; " on the j loop where there is a bracket.