Home
(current)
About
Tutorial
Technologies
C#
Deep Learning
Statistics for AIML
Natural Language Processing
Machine Learning
SQL -Structured Query Language
Python
Ethical Hacking
Placement Preparation
Quantitative Aptitude
View All Tutorial
Quiz
C#
SQL -Structured Query Language
Quantitative Aptitude
Java
View All Quiz Course
Q & A
C#
Quantitative Aptitude
Java
View All Q & A course
Programs
Articles
Identity And Access Management
Artificial Intelligence & Machine Learning Project
How to publish your local website on github pages with a custom domain name?
How to download and install Xampp on Window Operating System ?
How To Download And Install MySql Workbench
How to install Pycharm ?
How to install Python ?
How to download and install Visual Studio IDE taking an example of C# (C Sharp)
View All Post
Tools
Program Compiler
Sql Compiler
Replace Multiple Text
Meta Data From Multiple Url
Contact
User
Login
Register
FRESHER BELL ALL LANGUAGE ONLINE COMPILER
Write a program if length of string is even, the reverse the string: MIDDLE LETTER/Reverse first half of the string if string length is ODD
Languages
Java
C
C-99
C++
C++ 14
C++ 17
PHP
Perl
Python 2
Python 3
Ruby
Go Lang
Scala
Bash Shell
SQL
Pascal
C#
VB.NET
Haskell
Objective C
Swift
Groovy
Fortran
Brainf**k
Lua
TCL
Hack
Rust
D
Ada
R Language
Free Basic
Theme
github
xcode
ambiance
monokai
chaos
chrome
Program
import java.util.*; public class MidLetter { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String str=sc.nextLine(); int len=str.length(); if(len%2==0) { StringBuilder sb=new StringBuilder(str); sb.reverse(); System.out.println(sb.toString()); } else if(len%2!=0) { System.out.println("Length of string is " +len); int mid=len/2; mid++; System.out.println("Substring of string is "+mid); String substr=str.substring(0,mid-1); String remainSub=str.substring(mid-1,len); StringBuilder sb=new StringBuilder(substr); sb.reverse(); System.out.println(sb.toString()+remainSub); } } }
Run
Clear
Input
Samsung
Output
Powered By Fresher Bell™
Similar Program
#
Program
Language
1
Java program to add element to ArrayListv and get size of it
Java
2
Write a java program to find unique character in string
Java
3
Alternate Method 2 :Write a program to find anagram or two words of same letter
Java
4
Java program to convert Map (HashMap) to List (ArrayList)
Java
5
Java program to find LCM of two number taken by user using while loop
Java
6
Java Left Shift Operator Program
Java
7
Java Program to convert Character to String
Java
8
Java While Loop Example
Java
9
Java Method Overriding Example
Java
10
Write a java program to find alternate sum and difference of a given number
Java
11
Java program to convert hexadecimal to decimal
Java
12
Java Hierarchical Inheritance Example
Java
13
Java Bitwise Or Example
Java
14
Java Logical And Operator Example
Java
15
Java program to check whether number is prime or not
Java
16
Java program to find transpose of matrix
Java
17
Java program to find the root of quadratic equation.
Java
18
Java Relational Operator Example
Java
19
Java Program to multiply two decimal number ( floating number ) by taking input from user
Java
20
Java program to find average of numbers in the array
Java
#
Program
Language
Copyright © 2020
Inovatik
- All rights reserved