1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
/* Java String Array Example. This Java String Array example how to create and use String array or array of Strings in Java. */ public class JavaStringArray { public static void main(String args[]){ /* * Java String array can be created in below given ways. */ /* * Declare and initialize String array in single statement as given below. * This method is particularly useful when we are dealing with very small size array. */ String[] myFirstStringArray = new String[]{"String 1", "String 2", "String 3"}; /* * Declaration and assignment can be done separately as given below. */ //first declare String array String[] mySecondStringArray = new String[3]; //Observe that giving size is mandatory here. While there was no size given in the first method. //Now Assign individual String array elements mySecondStringArray[0] = "String 1"; mySecondStringArray[1] = "String 2"; mySecondStringArray[2] = "String 3"; //Note that, like every other arrays, String array starts with index 0 and not index 1. /* * Retrieve values from String Array: * * String array elements can be retrieved by directly accessing using index. You may also iterate * String array using loop. */ //this will retrieve second element of first String array System.out.println(myFirstStringArray[1]); //iterate the String array using loop for(int i=0; i < mySecondStringArray.length; i++){ System.out.println(mySecondStringArray[i]); } } } /* Output of the above Java String Array Example program would be String 2 String 1 String 2 String 3 */ |
Given an array of strings as input, return an array of all strings that have repeated chars that appear together. For e.g. in “hello” l and in “summer” s is a repeated char that appears together. However in “robot” o is not a repeated char as it does not appear together.
repeatChars({“hello”,”robot”,”summer”,”elephant”}) = {“hello”,”summer”}
Thanks very much ,Such a useful examples are you posted .I like all examples!!! one again thanks…..
java progrmme for login function using single arrat