WHAT'S NEW?

charAt() of String

charAt() of String class is a simple method to find out the character at a particular position in the String.


Structure of charAt() looks like

public char charAt(int index)
- Returns the character at a particular index in the String


Lets say for String "Zartab", if i need to find what is the character at index number

So now to get any character at location let say 4, we need to write the code as

String str="Zartab";
char c=str.charAt(4);
System.out.println(c);

c will return 'A'.

The whole will look like

class CharAtDemo 
{
public static void main(String[] args) 
{
String str="ZARTAB";
char c=str.charAt(4);
System.out.println(c);
}
}


1 comment: Leave Your Comments

  1. Three Card Poker is a stud poker game that gives 3 ways to play and 4 different ways to win. Players may wager in opposition to the dealer or wager on 점보카지노 the value of their very own three-card hand or wager both. Bonus payouts additionally be} received for certain palms when wagering in opposition to the dealer. The "Ante Bonus" is paid when a player is dealt one of the three highest rating palms within the game.

    ReplyDelete