Click here to Skip to main content
15,908,112 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
[Q: (software: netbeans7.1) In this program if i want to see the output(as shown below) in a GUI design then how should i proceed.. should i use (from new file in category option we will get )javaSwing Form and JFrame form (in FileType) ??
Where can i get the exact gui design for beginners book, so that i can download and do my work properly....] plz help

Java
public class CharacterinaStringAfterreplacement {// class name declaration
    public static void main(String[] args) {// main program start here//
        String s1="H.R System Finance Marketing";// string declaration (original)
        String s2="Finance";// string that is to be replaced
        String s3="Monitoring";// string that is to be assigned in result//
        String s4=s1.replace(s2,s3);// method for replacement of s1 (original)//
        int n=s1.length();//before replacement// length method for calculating the number of character in the replacement string// 
        int m=s4.length();//after replacement//length method for calculating the number of character original string// 
        System.out.println("1. *After* replacement of this string we are getting number of character like this below :)");
        System.out.println(s1.replace(s2, s3));
        
        
        System.out.println("number of character is ="+s4.length());
        System.out.println("2. *Before* replacement of the string we had the following number of character of this string :) ");
        System.out.println(s1);
        System.out.println("number of character is ="+s1.length());
    }
}

output:
run:
1. *After* replacement of this string we are getting number of character like this below :)
H.R System Monitoring Marketing
number of character is =31
2. *Before* replacement of the string we had the following number of character of this string :)
H.R System Finance Marketing
number of character is =28
BUILD SUCCESSFUL (total time: 0 seconds)
Posted
Updated 24-Apr-12 19:14pm
v3

 
Share this answer
 
String replacement - nice. I rated it homework - cause that's what it is.

Java
String s1="H.R System Finance Marketing";
String s2="Finance";
String s3="Monitoring"; 
String s4=s1.replace(s2,s3);


You don't need to hold the length of the strings in int variables. Just ask the String on the fly, that is much better as the length is not needed anywhere else.

For the GUI design - yes, stick to Swing for the start. You are using Netbeans - there should be a pretty good WYSIWYG-Editor in there.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900