Thursday, December 24, 2015

Character Extraction

Character Extraction:


1) charAt()


charAt() method is used to extract single character from String.Here is a small program to demonstrate chatAt() method.  


package stringdemo;


public class NewClass {
    public static void main(String[] args) {
       
      String  ch="java";
        System.out.println(ch.charAt(1));
    }
}

The output of this program is as:
a

Related Posts:

  • Do-While loop:Do-While loop: package javaapplication27; public class DowhileLoop {     public static void main(String[] args) {       &nbs… Read More
  • java while loopjava while loop package javaapplication27; public class WhileloopDemo {     public static void main(String[] args) {       … Read More
  • Nested Loop:Nested Loop: package javaapplication27; public class NestedLoop {     public static void main(String[] args) {       &nbs… Read More
  • Method with Parameter in javaMethod with Parameter in java package javaapplication27; public class MethodWithParameter {     double width;     double height;… Read More
  • Recursion Function in java:Recursion Function in java: public class Factorial {     //this is recursive function     int fact(int n){     int resu… Read More

0 comments:

Post a Comment