Home Answers Viewqa Java-Beginners java program(strings)

 
 


Manish
java program(strings)
1 Answer(s)      4 years and 6 months ago
Posted in : Java Beginners

View Answers

December 4, 2008 at 11:03 PM


Hi friend,

Code to solve the problem :

class JavaStringExample
{
public static void main(String[] args)
{
String str1 = args[0];
String str2 = args[1];
int str1Count=0;
int str2Count=0;
for(int i=0;i<str1.length();i++)
{
if(str1.charAt(i)=='a' || str1.charAt(i)=='A')
{

str1Count++;

}
}
for(int i=0;i<str2.length();i++)
{
if(str2.charAt(i)=='a' || str2.charAt(i)=='A')
{
str2Count++;
}
}
int totalCount = str1Count+str2Count;
String str11replace = str1.replace('a','@');
String str12replace = str11replace.replace('A','@');

String str21replace = str2.replace('a','@');
String str22replace = str21replace.replace('A','@');

System.out.println("The total number of occurrences of the character 'a' or 'A' : "+totalCount);
System.out.println("String 1 Replace : " + str12replace);
System.out.println("String 2 Replace : " + str22replace);
System.out.println("String 1 Uppercase : " + str12replace.toUpperCase());
System.out.println("String 2 Uppercase : " + str22replace.toUpperCase());
String strResult = str12replace.toUpperCase()+ str22replace.toUpperCase();
System.out.println("String Result : " + strResult);


}
}


Thanks









Related Pages:
strings
strings  write a program in java to accept two strings as command line arguments and perform the following operations-: 1) compare the strings 2... is an example which accept two strings as command line arguments and perform
strings
strings  java program for removing multiple spaces into single space
java program(strings) - Java Beginners
java program(strings)  Write a program in Java which accepts 2 strings as command line arguments. The program should do the following: i) print... in both the strings ii) replace every occurrence of ?a? or ?A? by @ iii) convert
strings in java
strings in java  please explain me the flow of this program..not able to execute correctly n wats the use of clone public class Strclone { public static void main(String args[]) { String s=new String("a"); String s1
strings
strings  Write a program to initialize 7 names in an array and their respective roll numbers in another array. Search for a roll number input by the user ,in the list ,If found display "Search Successful" and print the name along
strings
strings  1.Create a class named BuilderDemo. Use the string builder method to get the following output from string s4 Consider: String s4 = â??Java...) { String st="Java is an OO"; String str[]=st.split(""); String reversedSt
strings
strings  1.Create a class named BuilderDemo. Use the string builder method to get the following output from string s4 Consider: String s4 = â??Java...) { String st="Java is an OO"; String str[]=st.split(""); String reversedSt
Insane Strings - Java Tutorials
Insane Strings 2001-03-21 The Java Specialists' Newsletter [Issue 014] - Insane Strings Author: Dr. Heinz M. Kabutz If you are reading this, and have... of "The Java(tm) Specialists' Newsletter", where we look at things that other
STRINGS - Java Beginners
STRINGS  WRITE A JAVA PROGRAM TO REVERSE THE ORDER OF WORDS IN THE SENTENCE...EXAMPLE" " "ANT EATS APPLES"SHOULD BE RETURNED AS" "APPLES EATS ANT" THANK YOU SIR..WAITING EAGERLY FOR THE ANSWER......!!!!!!  Hi
strings in java(18 june ,2011)
strings in java(18 june ,2011)  please explain me the flow of this program..not able to execute correctly n wats the use of clone public class Strclone { public static void main(String args[]) { String s=new String
strings in java(18 june ,2011)
strings in java(18 june ,2011)  please explain me the flow of this program..not able to execute correctly n wats the use of clone public class Strclone { public static void main(String args[]) { String s=new String
Follow-up to Loooong Strings,java tutorial,java tutorials
Follow-up to Loooong Strings 2002-11-13 The Java Specialists' Newsletter [Issue 059b] - Follow-up to Loooong Strings Author: Dr. Heinz M. Kabutz... was "Verrrrrry looooong Strings and other things". One of my subscribers from Poland
concatinate 2 strings - Java Interview Questions
concatinate 2 strings   Write a program to concatenate two strings ?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/CombinString.shtml Thanks
strings 20june
strings 20june  please explain me the flow of this program..not able to execute correctly n wats the use of clone public class Strclone { public static void main(String args[]) { String s=new String("a"); String s1 = "Hello
programes on strings
programes on strings   a. write a program to copy one array to another array using System.arrayCopy() method. b. write a program to check whether entered string is palindrome or not.   Have a look at the following link
Strings in Switch statement
C:\Program Files\Java\jdk1.7.0\bin>javac StringsInSwitch.java C:\Program Files\Java\jdk1.7.0\bin>java StringsInSwitch End...Strings in Switch statement In this section, you will learn about strings
compare two strings in java
compare two strings in java  How to compare two strings in java...) { System.out.println("The two strings are the same."); } } } Output: The two strings are the same. Description:-Here is an example of comparing two
hash function for java strings
hash function for java strings  hash function for java strings   int hash=7; for (int i=0; i < strlen; i++) { hash = hash*31+charAt(i
java program
java program  i want a applet program that accepts two input strings using tag and concatenate the strings and display it in status window. please give mi he code for this in core java
java program
java program  i want a applet program that accepts two input strings using tag and concatenate the strings and display it in status window. please give mi he code for this in core java
java program
java program  i want a applet program that accepts two input strings using tag and concatenate the strings and display it in status window. please give mi he code for this in core java
Grouping strings - Java Beginners
Grouping strings  I have written a code to determine the lengths of strings. What I need to do is to group strings that are within a certain range, say 15 to 20, 21 to 30, etc. Is there any one out there with an idea?  
Strings - Java Beginners
Strings  Normally when we assign one object to the other, a copy of the reference is created and both these references point to the same object. eg: Obj o1=new Obj(); Obj o2=o1; But is case of Strings, how
Appending Strings - Java Tutorials
.style1 { text-align: center; } Appending Strings In java, the two main ways for appending string at the end are : First method is using += operator. Second method is using append()  method. In this section, we
To check the Rotational Strings are Equall or not
To check the Rotational Strings are Equall or not  I attended 3dplm software company interview....there asked one question related to Strings.The question is................. Write a program to check the given two strings
STRINGS - Java Interview Questions
STRINGS  1.Why string objects are immutable? 2.why java is pass by value?  Hi Friend, 1) To save memory, java can refer two string.... 2) In Java,when you call a method,a copy of the value of each actual
Comparing strings - Java Beginners
."); } } } -------------------------------------------------------------- Read for more information. http://www.roseindia.net/java
JAva program
JAva program  Write a JAva program that takes various string from command line and display them in sorted order.   Java display strings...); System.out.println("Enter 5 strings: "); String array[]=new String[5
validation of strings using java function
validation of strings using java function  hi all, i am uploading data from csv file to data base where i took student id as string of length 6 char of the form abc123 will you please give me a function to validate this field
Java create new array of strings.
Java create new array of strings.  Java create new array of strings.   Example: public class StringArray { public static void main(String[] args) { String name[] = { "mandy", "Rixi", "Ron
Java Program
Java Program  Hi, please share the code to check, if two strings are permutations of each other in java.   Here is an example that prompts the user to enter two strings in order to check whether they are permutation
searching for strings in a file
searching for strings in a file  how can i search of a person and display the other details associated with the name using java gui window?  ...://www.roseindia.net/java/example/java/swing/addeditanddeleteemployee_inf.shtml
strings
strings   read sentence and convert all the word into capital case like camelcase   Hi Friend, Try the following code: import java.util.*; class ConvertWordsIntoUpperCase { public static String toCamelCase(String
Strings
will contain strings which is separated by ",". From the main method invoke
Java Program
Java Program  How to Write a Java program which read in a number... out in the standard output. The program should be started like this: java... into a fixed size buffers of strings. The buffer can store at most 10 strings
strings - Development process
("Convert Value in int " + i); } } For more information on Java visit to : http://www.roseindia.net/java/ Thanks
To get the String between two strings
To get the String between two strings  How to get string between two strings repeatedly using java?   Hi, Please tell me more about what do you want to achive. Thanks
Java Strings problem - Java Interview Questions
Java Strings problem  How can you find a word which is repeating in maximum number of times in document, which is in text format in java?  ...()); } } } For read more information : http://www.roseindia.net/java
question about mixing two strings
question about mixing two strings  using java script we need to ask two strig and combine them like.. str1= helo str2= worl combined string= hweolrol
java program - Java Beginners
java program  Hi Friends i have one small doubt!! code for arry to print some strings with out allowing duplicate Strings?  Hello Go to the concept pf array, it always allow duplicate. if u want ur contain unique
Converting Numbers to Strings
Java: Converting Numbers to Strings Vanilla Java: Converting numbers to strings is easy. You can do almost everything with concatenation, but can get more... DecimalFormat, but as soon as the Java 5 format() and printf() methods are better
java Program - Java Beginners
java Program  1. Write a java program to accept 10 numbers in an array and compute the sum of the square of these number. 2. Wrtie a java program that reads in three strings from the command line arguement and arrange them
formatting program
formatting program  Hi I needs some help with this program on formating can anyone help?The details of the program are stated below, thanks. This program should be an example of how Java lets you format numbers and strings
String program - Java Beginners
String program  write a program to accept a word. Pass it to the function magic(String x). The function checks the string for the presence...;import java.util.Scanner; public class Strings { public String cons
Program
Program  Create two strings s1=â??Javaâ?? and s2=â??Programmingâ?? using string Buffer class and perform the following operations. i) Append s1 and s2. ii) Reverse string s1. iii) Find length of string s1 and s2. iv) Replace

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.