Can someone help me with this simple java code and clear my concepts

import java.util.Scanner;

class chara {

public static void main(String args[]) {

int T, l, i;

Scanner sc = new Scanner(;

System.out.println("enter test cases");

T = sc.nextInt();

String S = sc.nextLine();

for (i = 0; i < T; ++i) {

System.out.println("enter a string");

S = sc.nextLine();





On the first iteration it does not ask for input in string it executes to the next line, from the second iteration it asks.Can someone please help me with this basic doubt in java and clear my concepts....

Read More »

By: StackOverFlow - Friday, 9 November

Related Posts