Q:

Write a Java program to extract the first half of a string of even length

0

Write a Java program to extract the first half of a string of even length
Test Data: Python
Sample Output:

Pyt

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.lang.*;
 public class Exercise69 {
 public static void main(String[] args)
 {
    String main_string = "Python";    
    System.out.println(main_string.substring(0, main_string.length()/2));	
  } 
 }

Sample Output:

Pyt

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now