I am new to Java so I am trying to write some simple applications that I will need to enhance later for a new project I need to implement.
The program I am writing should be simple. It removes one word from a statement and changes it with another. I thought a simple getChars would do it but when I try to compile it, I get a start of expression error and I am just not getting things enough yet to find the error.
The code is:
/**
Replaces the first occurrence of "hate" in a String with the word "love".
*/
public class LoveHate
{
/**
The String in which a word is to be replaced
*/
public static final String ORIGINAL = "I hate you.";
public static void main(String[] args)
{
// Print the original string
System.out.println("The line of text to be changed is:");
System.out.println(ORIGINAL);
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
{
String REPLACE = "Love";
srcBegin = REPLACE(0);
srcEnd = REPLACE(3);
dst = ORIGINAL(2);
dstbegin + (srcEnd-srcBegin) - 1
}
// Construct and print the changed text
System.out.println("I have rephrased that line to read:");
System.out.println(start + "love" + end);
}
}
Am I even close here?
Any help with this is really appreciated.
Thanks,
TB
The program I am writing should be simple. It removes one word from a statement and changes it with another. I thought a simple getChars would do it but when I try to compile it, I get a start of expression error and I am just not getting things enough yet to find the error.
The code is:
/**
Replaces the first occurrence of "hate" in a String with the word "love".
*/
public class LoveHate
{
/**
The String in which a word is to be replaced
*/
public static final String ORIGINAL = "I hate you.";
public static void main(String[] args)
{
// Print the original string
System.out.println("The line of text to be changed is:");
System.out.println(ORIGINAL);
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
{
String REPLACE = "Love";
srcBegin = REPLACE(0);
srcEnd = REPLACE(3);
dst = ORIGINAL(2);
dstbegin + (srcEnd-srcBegin) - 1
}
// Construct and print the changed text
System.out.println("I have rephrased that line to read:");
System.out.println(start + "love" + end);
}
}
Am I even close here?
Any help with this is really appreciated.
Thanks,
TB