Queries for characters in a repeated string | Java Program to Queries for same characters in a repeated string ; Print whether index i and j have same element or not ; Finding relative position of index i , j ; Checking is element are same at index i , j ; Driver Code
import java . io . * ; public class GFG { static void query ( String s , int i , int j ) { int n = s . length ( ) ; i %= n ; j %= n ; if ( s . charAt ( i ) == s . charAt ( j ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } static public void main ( String [ ] args ) { String X = " geeksforgeeks " ; query ( X , 0 , 8 ) ; query ( X , 8 , 13 ) ; query ( X , 6 , 15 ) ; } }