Hi everybody I am so New in Java or rather not really able to understand Java yet.
I have assignment where I do not know how to think anymore..is probably very easy to those who understand programming but sadly I do not.
Program should do:
1. assign any amount of different strings.
2. user is giving any letter he/she wants and program to find it among given strings.
If searched letter is in any string/ strings , only these strings or string are printed.
3. If in given strings is not searched letter, program has to say it, for ex: there is not letter you search for.
As long as now I have only, strings assigning to array. So there are strings in array but I do not know how to write code where I can find given letter by user.
I just do not know how I should think(anymore at all ;)) here. I am really frustrated and desperate, how to understand this?? Once and for all!!!
I was thinking maybe I should use ArrayList? but how...or Can it be done both ways with Array or with ArrayList?
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("How many strings ?");
int antal= scan.nextInt();
String [] str = new String[antal];
String string = null;
int x;
scan.nextLine();
for( x=0;x<str.length;x++){
System.out.print("String "+(x+1)+": ");
string= scan.nextLine();
str[x]= string;
}
System.out.print("Write a letter you wish to find :");
String letter = scan.nextLine();
char check = letter.charAt(0);
//somthing in here ....