katy
character counter
2 Answer(s)      6 years and 2 months ago
Posted in : Java Beginners
Advertisement
View Answers

March 29, 2009 at 5:31 AM


hy katy,


import java.io.*;
class counter
{
public counter()
{
System.out.print("Enter ur name:");
try{
BufferedReader in2=new BufferedReader(new InputStreamReader(System.in));
String name = in2.readLine();
char c[] = name.toCharArray();
if(name.length() <=4 ){
System.out.println("Name Length must be above 3 characters!!");
}
else{
System.out.println("First Three Character is:"+c[0]+c[1]+c[2]);
}

}catch(IOException io){
System.out.println(io);}
}
public static void main(String args[])
{
new counter();
}
}




this code will full fill your require, i hope
thnx.




satish,
talkin.satishz@yahoo.com


March 30, 2009 at 3:02 PM


hi katy,

You can also used substring() method of string object to show first three characters of entered name.

import java.io.*;
class GetCharacter
{
public GetCharacter()
{
System.out.print("Enter name:");
try{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String name = br.readLine();
String st=name.substring(0,3);
System.out.println(st);
}
catch(Exception e){}
}
public static void main(String args[])
{
new GetCharacter();
}
}

Thanks
RoseIndia Team










Related Tutorials/Questions & Answers:
character counter - Java Beginners
character counter  how to show only first three characters of the entered(by user) name?  hy katy, import java.io.*; class counter { public counter() { System.out.print("Enter ur name:"); try
Servlet Counter
{ int counter = 0; public void doGet(HttpServletRequest request...(); counter++; pw.println("At present the value of the counter is " + counter); } } In the above example, which keeps track how many times the servlet
Advertisements
Counter program for java
Counter program for java  The problem is to count from 000 to 444 with recursion. The maximum digit is 4 so that the program will count from 000,001,002,003,004,010, 011 and so on. How can I solve
counter - JSP-Interview Questions
********///////// A page with a counter This page has been visited: times. This counter never increases its value
Character count by while loop
Character count by while loop  Write the program to count the number...(); for(int counter =0;counter<third.length;counter++){ char ch= third[counter...]) flag=true; } if(!flag){ System.out.println("Character :"+ch+" occurs "+count
Using Bean Counter in JSP
Using Bean Counter in JSP       In this section you will learn how the counter bean can be used in jsp. As you all know a counter increments the value by one. Here, we will use
Character Class
Character Class  Character defines the forDigit();,digit()methods..how can these b used and wht is radix point signifies here...in the arguments of these two???..pls answer a code on this with radix .. are these methods also
Character class
Character class   Character defines the forDigit();,digit()methods..how can these b used and wht does radix point signify here.i want to knw what basically radix is??here in the arguments of these two???because i tried runnin
underscore as character
underscore as character  how can i consider _ as a character instead of wildcard character? my problem is like this i have 20 records as follows manohar 1234455 manohar 453635 manohar 345454 manohar_1234455 now when i am
Hit Counter Schema using java script - WebSevices
Hit Counter Schema using java script   Dear Sir, I am sending you none project i need you help please tell me how to do it? first I have... counter of 0-9 and then switch to an alphabet for 10 and above. After going over
Simple Counter In Servlet
Simple Counter in Servlet     ... a program on counter which will keep track how many times the servlet has been... making a class define one variable counter which will keep record for how many times
count the repeated character in one string
count the repeated character in one string  to find the how character...=str.replaceAll(" ", ""); char[]third =st.toCharArray(); for(int counter =0;counter<third.length;counter++){ char ch= third[counter]; int count=0
How to convert entity character to html character
How to convert entity character to html character  How to convert entity character to html character
JSP Session Counter Using SessionListener
JSP Session Counter Using SessionListener          Counter is a device... counts upwards and the second one is downward counter which counts from up
How to convert entity character to html character
How to convert entity character to html character  Please help me to "convert entity character to html character" in java. If possible please provide source code which take String as input and return as String
replace character in php
replace character in php  PHP script that replace character
I don't know how to use counter variable in this Qustion ....:(
I don't know how to use counter variable in this Qustion ....:(  Declare and initialize value of array in int type. read and assgin all the mark to every students by using counter variable, k. output should be like
Character Wrapper Class.
Character Wrapper Class.  what are Mirrored Unicode Characters?? and whats the use of "isMirrored(ch);method ??.where ch is any character argument.... There are special characters in UNICODE to achieve the RTL. Such character is the Mirroring
character as command line arguments
character as command line arguments  public class testing { public static void main(String args[]) { char a; a=args[0]; System.out.println("character is:"+a); } } what will be the above program output
Create a counter in mySQL 5 database through Java - SQL
Create a counter in mySQL 5 database through Java  Dear Editor, Thanks for your valuable Java code example for JFileChooser. I had another... for 12 times. May i know how to create a counter (some sort like word search
How to display string or character
How to display string or character  how to print character or a word without using array concept
password validation with special character
password validation with special character  how to validate password with special character using java script
find the first character is vowel or not
find the first character is vowel or not  hi friend, can u plz send me javascript code for find the wether the first character is a vowel or not. 2) check wether the last character is same as the first character or not 3) check
php remove last character
php remove last character  to remove the last character, i used the trim function which is not working
JavaScript regex validate Character
Character.   <html> <head> <title>Character validation... Character value : "+name); return true; } alert("It is not valid character !"); return false; } </script> <
JavaScript regex validate Character
Character   <html> <head> <title>Character validation... Character value : "+name); return true; } alert("It is not valid character !"); return false; } </script> <
Character Directions in java
Character Directions in java  java 2,version 1.4 adds a method "getDirectionality();" , what is the use of this method ?   This method returns the Unicode directionality property for the given character. Character
What is Character Functions
What is Character Functions  What is Character Functions   Hi, Here is the answer, Character Functions are INITCAP, UPPER, LOWER, SUBSTR & LENGTH. Additional functions are GREATEST & LEAST. Group Functions
Wrapper Character class.
Wrapper Character class.  How do the methods 'isIndentifierIgnorable(ch)' and 'isISOControl(ch)' work?? while workin with 'Character' wrapper class...: This method returns true if the character may be part of a Unicode identifier; false