tong1 22 Posting Whiz

NormR1, thank you very much for your advise. Accordingly, I would like to replace the code on line 5 in the first poster by:

String pc [][]=new String[Suit.values().length][Rank.values().length];

It works.

tong1 22 Posting Whiz

No. I meant that the header you used in line 4 on the second last poster on page 1:
import javax.swing.JOptionPane.*;
is wrong. No such a package. JOptionPane is a class.

tong1 22 Posting Whiz

I am interested in Current threads, such as :
rare program :s
http://www.daniweb.com/forums/thread300723.html
how to create 2D array of enumeration values
http://www.daniweb.com/forums/thread300738.html
which have a common goal: to store the names of Enums objects in a 2D array of String.
For example, we have a pack of porker cards defined by the following two enums:
enum Rank { DEUCE, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE }
enum Suit { CLUBS, DIAMONDS, HEARTS, SPADES }
(1) One should declare a String paker[][]= new String[4][13]; to store all (52) the cards.
(2) If one is asked to store two enums in a 2D array of String respectively one may create a 2D array to have their names:

String set[][]= new String[2][];
set[0]= new String[2];
set[1]= new String[13]

I have written a program where the 52 (4×13) cards are presented. However, I have following questions. Please help me to understand Enum in Java correctly.
1. Does the class Enum has a method by which one may know how many objects in this Enum class. That is, how do we know the “legnth” of an enum.
2. In API one may see Enum class while in coding one sees enum. Hence I would ask what is the differences between Enum and enum?
3. Why any class defined by a programmer can not inherit Enum?

I appolozige in advance for the incorrect/improper …

tong1 22 Posting Whiz

Start with Java tutorial on the Internet, e.g.
http://download-llnw.oracle.com/javase/tutorial/
Some text books, such as Java How to program by H.M. Deitel, P.J.Deitel is also good.

tong1 22 Posting Whiz

One may also use the ordinal() method to provide index for the twoDim so that the int i could be saved.

String twoDim[][] = new String[2][5] ;
   for ( Days day : Days.values())
      twoDim[0][day.ordinal()]=day.name();

   for (Periods prds : Periods.values()) 
      twoDim[1][prds.ordinal()]=prds.name();
tong1 22 Posting Whiz
tong1 22 Posting Whiz

To store two Enum type objects:
enum Days {Mon, Tues, Wed, Thurs, Fri}
enum Periods {Period1, Period2, Period3, Period4, Period5}
in a 2D String array, one should start with the line of code :

String twoDim[][]= new String[2][5]; // Xufyan incorrectly wrote new String[5][5]

Then we may store the values in the String 2D array twoDim with the following code without "go-between". I also noticed that as NormR1 indicated, the method name() should be used since enums are not Strings.

twoDim = new String[2][5] ;
   int i=0;
  for ( Days day : Days.values() )
   twoDim[0][i++]=day.name();
      i=0;
  for (Periods prds : Periods.values()) 
   twoDim[1][i++]=prds.name();
tong1 22 Posting Whiz

I wonder if the following way is a candidate answer for Xufyan's question?
Should we make Days type 1D array and Periods type 1D array to play a go-between role? Then use the method name() to store the names in two final String arrays?

public class Enumeration0 {
  enum Days {Monday, Tuesday, Wednesday, Thursday, Friday}
  enum Periods {Period1, Period2, Period3, Period4, Period5}
  
    public static void main(String[] args){
    String sd[]=new String[5]; // allocate String array sd
    String sp[]=new String[5]; // allocate String array sp
    Days d[] = Days.values();  // create Days array d with values of Days
    Periods p[]=Periods.values(); // create Periods array p with values of Periods
    
    for(int i=0; i<5; i++){  // store the enum values in String arrays: sd and sp 
	sd[i]=d[i].name();
	sp[i]=p[i].name();
		}
    for (String  s : sd)   // print String array sd
	System.out.print(s + " ");
	System.out.println();
    for (String  s : sp)  // print String array sp
	System.out.print(s + " ");
	System.out.println();
	}
}
tong1 22 Posting Whiz

A method to declare and allocate Xufyan's ladder array is written as follows so that the creation of the array seems further concisely in main method.

public class array{
	
	static int[][] allocateLadderArray( boolean up){
		int [][]a; // declare 2D array a
		a = new int[4][]; // allocate spaces for 4 rows, i.e. declare 4 1D arrays
		for (int i=0; i<4; i++) // allocate spaces for the 2D Latter array
		if (up)
		a[i] = new int[4-i];
		else
		a[i] = new int[i+1]; 
		return a;   // return the reference of the allocated array
	}
	static void printArray(int a[][]){
	 for ( int i=0; i<a.length; i++ ){
     for ( int j=0; j<a[i].length; j++ )
     System.out.print (a[i][j] + " ");
     System.out.println ("");
     		} 
     }
     static void assignValues(int a[][]){
     int k=100;
       for (int i=0; i<a.length; i++ )
     for (int j=0; j<a[i].length; j++ ) {     
     a[i][j] = k;
     	k = k-10;
     }	
     }

public static void main (String [] args){

 	int [][] TwoDArray1 = allocateLadderArray(true);  //return a reference of an allocated ladder array to TwoDArray1
 	int [][] TwoDArray2 = allocateLadderArray(false); //return a reference of an allocated ladder array to TwoDArray2
   	
	assignValues(TwoDArray1); // assign initial values to every elements of the 2D array TwoDArray1
	assignValues(TwoDArray2); // assign initial values to every elements of the 2D array TwoDArray2
   	printArray(TwoDArray1); // print all elemens in format of rows and columns 
   	printArray(TwoDArray2); // print all elemens in format of rows and columns 
  }
}
tong1 22 Posting Whiz

Mirage,
(1) NormR1 wants you to know that JOptionPane is a class rather than a package. In your program you use JOptionPane which is in the package : javax.swing. Therefore your import statement should be either:
import javax.swing.*:
or
import javax.swing.JOptionPane;
(2) You have no need to use an input via DOS since you use the JOptionPane
(3) You should learn how to use JOptionPane to create an input. Please read API for the class JOptionPane
I have written a simple code showing how it works.

import java.io.*;
import javax.swing.JOptionPane;
 public class Mirage0{
  public static void main (String args[])throws IOException {
  String str =JOptionPane.showInputDialog("Please Enter an integer a:");
  int a=Integer.parseInt(str);
  str =JOptionPane.showInputDialog("Please Enter another integer b:");
  int b=Integer.parseInt(str);
  JOptionPane.showMessageDialog(null, "The sum of a and b :" + (a+b));
     }
}
tong1 22 Posting Whiz

I have implemented Xyfuan's latter arrays using two methods: static void init(int a[][]) to assign initial values to each elements and static void printArray(int a[][]) to print a 2D array. it works. Please check if there are any improper remarks/comments.
The output:
100 90 80 70
60 50 40
30 20
10
100
90 80
70 60 50
40 30 20 10

The code:

public class array{
     static void printArray(int a[][]){
     for ( int i=0; i<a.length; i++ ){
       for ( int j=0; j<a[i].length; j++ )
       System.out.print (a[i][j] + " ");
       System.out.println ();
     		} 
     }
     static void init(int a[][]){
     int k=100;
     for (int i=0; i<a.length; i++ )
       for (int j=0; j<a[i].length; j++ ) {     
       a[i][j] = k;
       k = k-10;
     }	
     }

public static void main (String [] args){

 	int [][] TwoDArray1; // declare 2D array TwoDArray1
 	int [][] TwoDArray2; // declare 2D array TwoDArray2
 	TwoDArray1 = new int [4][]; // allocate spaces for 4 rows, i.e. declare 4 1D arrays
	TwoDArray2 = new int [4][]; // allocate spaces for 4 rows, i.e. declare 4 1D arrays
   	for (int i=0; i<4; i++){
  	TwoDArray1[i]= new int[4-i]; // allocate spaces for the 2D array TwoDArray1
   	TwoDArray2[i]= new int[i+1]; // allocate spaces for the 2D array TwoDArray2
   	}
   	
	init(TwoDArray1); // assign initial values to every elements of the 2D array TwoDArray2
	init(TwoDArray2); // assign initial values to every elements of the 2D array TwoDArray1
   	printArray(TwoDArray1); // print all elemens in format of rows and columns 
   	printArray(TwoDArray2); // print all elemens in format of rows and columns 
  }
}
tong1 22 Posting Whiz

(1) Different from C/C++,in Java the following array declaration and allocating space is not allowed:
int arrey [3][3];
(2) the following way to have your arrey is valid:
int arrey[][]; //declaration of a 2-D array
arrey = new int[3][3]; //creates corresponding space for the array arrey with no values assigned.
Then you have to write code to assign values to its elements:

int value=1;
for (int i=0; i<arrey.length; i++)
for (int j=0; j<arrey[i].length;j++)
arrey[i][i]=value++;

(3) Another way to have your arrey: in Java you may declare a array, allocate space, and assign values to it at the same time ( in one line of code), like:
int arrey[][]= {(1,2,3},{4,5,6},{7,8,9}}; //declare, allocate, and assign initial values

tong1 22 Posting Whiz

In line 1 the condiction for while loop answer.equalsIgnoreCase("Y") repeats once.
Why?

tong1 22 Posting Whiz

glamourhits,
as an exercise, you may create more JOptionPane window by the end of the while loop to ask cleint: " Would you like to enter another Student Grade " after each run.
Also you may use "break" instead of System.exit(0) to terminate the loop. Try different code.

tong1 22 Posting Whiz

Replace line 40 by the following code:

name=JOptionPane.showInputDialog("Enter Student's full Name:\nClick Cancel to terminate program");
if (name==null) {
	JOptionPane.showMessageDialog(null,"Bey for now.","Welcome to DANIWEB", JOptionPane.INFORMATION_MESSAGE);
	System.exit(0);
}

This is to set up a guard so that if client clicks cancel button, the program may terminate.

Replace your main method with the following method where the while loop seems endless. This is what jon.kiparsky said: " to use one of these structures to make this run forever ". However, the above guard may terminate the program by calling System.exit(0). Therefore, the while loop in fact does not run forever.

public static void main(String[] args)
{
 	Student s = new Student();
 	while(true){
	s.inputGrades();
	System.out.println("Average --> " + s.getAverage());
	System.out.println("Letter grade --> " + s.letterGrade());
	System.out.println("s.toString() --> " + s.toString());
	}
}
tong1 22 Posting Whiz

Java has no destructor. If you want to dereference an object of DERIVED class, you may assign a null to the reference of the object so that calling the System.gc() will return the corresponding space to the OS sometime later. The garbage collector soon or later will collect it no matter if you put the line code: System.gc() or not.

see
"
# every class inherits the finalize() method from java.lang.Object
# the method is called by the garbage collector when it determines no more references to the object exist
# the Object finalize method performs no actions but it may be overridden by any class
....
"

to know more.

tong1 22 Posting Whiz

JDBC and MS Access is a good choice as you indicated. In addition to sports, may I mention about some other topics.
Depending on the data source available, and your own interests, you may work on a database for a particular research field.
For example for a research on political science, you may easily obtain some basic data on the presidency of USA and Canada.
For the World cup soccer 2010, you may concentrate on a specific aspect.
For the earth science your database could cover earthquake's disaster and prediction....

Technical discussion: Can we program JDBC in Java so that an image field from the MS Access database can be shown on a Java GUI?
Good luck

tong1 22 Posting Whiz

It could be:
int arrey[][]= {{1,2,3},{4,5,6},{7,8,9}};
May I suggest you write a method : void printArray(int a[][]); like the following code by red color to print any 2-D array.
When you create a two-demension ladder form in opposite way, some of the minor changes should be made. The following code works fine:

public class array{
public static void main (String [] args){
 int i, j, k = 100;
 int [][] TwoDArray;
 TwoDArray = new int [4][];
   TwoDArray [0] = new int [4];
   TwoDArray [1] = new int [3];
   TwoDArray [2] = new int [2];
   TwoDArray [3] = new int [1];

  for ( i=0; i<TwoDArray.length; i++ )
     for ( j=0; j<TwoDArray[i].length; j++ ) {     
     TwoDArray [i][j] = k;
     	k = k-10;
     }
   for ( i=0; i<TwoDArray.length; i++ )
     {
     for ( j=0; j<TwoDArray[i].length; j++ )
     System.out.print (TwoDArray [i][j] + " ");
     System.out.println ("");
     } 
  }
}
tong1 22 Posting Whiz

Or, The 40 line should be

answer = myScanner.next();

Then the program works. Remember, you should use the method next() instead of readLine() in this case.

tong1 22 Posting Whiz

If you want the first value to be 100 the following loop would be proper in line 13 - 17.

for ( i=0; i<TwoDArray.length; i++ )
     for ( j=0; j<=i; j++ ) {     
     TwoDArray [i][j] = k;
     	k = k-10; // equivalent to "k -= 10;"
     }

In your last version, the location of the curly brace after the loop control: for ( Row=0; Row<TwoDArray.length; Row++ ) should simply move immediately after the loop control: for ( Elements=0; Elements<=Row; Elements++ )

Xufyan commented: thanks alot +0
tong1 22 Posting Whiz

Yes, To replace "--k" with "k=k-10" is a proper way to do so. The --k is only for the purpose of one decrement. The '--' is an unary operator. There is no other unary operator for the purpose of , such as two- or three- decrement. You have to use the expression "k = k-10;" to do the job.

tong1 22 Posting Whiz

May I suggest in terms of your first post:
(1) replace line 10 by

while (answer.compareToIgnoreCase("Y")==0){

since tne comparison" answer == "Y" is the conpare references (addresses) of two instances.
(2) remove line 26 which seems useless
(3) line 40 should be:

answer = myScanner.nextLine();

the L in the method named "nextLine()" should be upper case.
I put one more line code after line 40:
answer = myScanner.nextLine();
( to "eat" the character '\n'???)
It works.

tong1 22 Posting Whiz
tong1 22 Posting Whiz

Your program can not be compiled successfully.
Where is your declaration for average,jgrade...
the code in line 26 is a dead loop if (average < 101)
The last curly brace is redundant that should be removed.

tong1 22 Posting Whiz

Not one line code. At least the first 5 lines.

tong1 22 Posting Whiz

Kdgeiger, where are your four methods? I guess your teacher would like to see a program written in the following structure as you indicated at your first post:

public class Prices {
double sum(double a[]); //the 1st creates a total of all values listed
double [] search (double a[], double d);//the 2nd searches the array and returns all values less than d (e.g. 5.00)
double average(double a[]);//the 3rd returns the average of the values using the output from the first method
double[] greaterThanAverage(double a[]);//finally the 4th method displays all values in the array greater than the average
public static void main (String[] args)
{
double[] prices = {1.59,8.98,2.56,7.82,9.70,2.85,
1.98,10.80,5.05,12.76,13.20,7.36,4.86,1.25,2.05,2.70,
9.98,4.25,13.05,6.00};
.....
}
}
tong1 22 Posting Whiz

Should we delete the break; in the line 29
since the

default:
valid=false;
break;

is the last case.

tong1 22 Posting Whiz

Animation in Java
JDBC application
Statistics on English words obtained from a text file
Some demonstration on data structure

tong1 22 Posting Whiz

Thank you for the comments.
I was wrong. It should be:
total += prices;

tong1 22 Posting Whiz

should be
total += prices;

tong1 22 Posting Whiz

jon, thank you for interpretation and clarification you made.

tong1 22 Posting Whiz

On Nov. 7th VernonDozier has clearly and correctly indicated the steps in writing a code to calculate. Please following the instruction write your own program.

tong1 22 Posting Whiz

I put your two java files into a folder with an image "dot.jpg". I have successfully compiled the MyApplet.java. Only one deformed image is shown in both ways: appletviewer and a browser. Check your image file name, your image file extension and other technical problems. It works in my folder.

tong1 22 Posting Whiz

Perter, Thank you for your advise.

tong1 22 Posting Whiz

Thank you for your information. I have tested on the web page. It works. Then I downloaded the code: TextFieldDemo.java and compiled it successfully. However, error messages appears when interpreting it by JVM:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:61)
at java.io.InputStreamReader.<init>(InputStreamReader.java:55)
at word.TextFieldDemo.<init>(TextFieldDemo.java:73)
at word.TextFieldDemo$1.run(TextFieldDemo.java:234)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

tong1 22 Posting Whiz

Dear NewOrder, jon's post is very important which tells you how to ask question precisely. Please read the web site jon indicates.
I explain how String Snumber="" works.
Each time when you declare String Snumber=""; you will have a new instance of String with no character. Then for example, after executing Snumber += "a"; the Snumber instance will change location to store "a". You should know the Sting instance is a constant which can not become larger like StringBuffer. If you want Snumber to have a 'a', you have to find a new location for Snumber. The String instances may work well with '+=' while StringBuffer instances shoud work with its method append(String s). You have placed the String Snumber =""; into the outerloop so that it becomes the fist line of the loop body. So each time when starting a new loop, a new instance of Snumber is created so that it will get ride of previous contents and store the next digit's string. Snumber changes location after each execution of '+=".
jon, am I right.
P.S. If you want to let some object, such as an instance of String Snumber, dead, you may use the code:
Snumber=null;
so that the garbage collector will return the Snumber to operation system.

tong1 22 Posting Whiz

Assuming that I have text in JTextArea where the characters are presented in different Font and colors since the class has a method :setFont(Font f), setForeground(Color fg).
I wonder if there is a way to save it on MS Word.

tong1 22 Posting Whiz

Thank you very much indeed for telling me the JFileChooser which I did not use before. I will study the JFileChooser via API. Your response is exactly I am looking for.
Could you please show me how to highlit a word in JTextArea? What method I should use?

tong1 22 Posting Whiz

jon, thank you for your quick response. You are right for the sake of exercise. For the purpose of exercise we should write our own code as much as possible. But after we made extensive exercises we should definitely know if there is a ready-made method in Java so that in the future, when working in software industry, we may simply use the ready-made methods instead of our-own made if the code we made is not better than the ready-made.

One question for students:
Why class String has no reverse() method?

tong1 22 Posting Whiz

Thank you for your quick response. To make the project better or perfect is my intention. Yes we have to write code by ourselves. But you may provide more specification to this kind of a project please, which is what I am looking for. There are at least two threads discussing about the titles of a graduation project, but no any concrete outcome. My thread is a specific one.

tong1 22 Posting Whiz

The following project is considered appropriate for a graduation dissertation in Computer Science
Graduation project if the supervising professor is good in Java
An English Word Statistics in Java
The function may include:

1. To ask client to select a text file to open (FileDialog would be good to start with)
2. To read the opened file word by word so that a String array/linked list(or other structures such as Vector…) may store each word with its frequency (i.e. the time of appearance of a word on the file).
3. Create a GUI where a Textarea (JtextArea would be good) instance showing whole text and conresponding outcomes upon requests
4. Upon sorting request by client, all the words will be shown in the textarea in a descending/ ascending order, or in terms of appearing frequency
5. Upon search request, a client will be asked to submit a word to be searched. In return, in the text area the outcome will indicate whether the word is found or not. If it is found, the appearance frequency will be shown as well.
6. The result and other messages could be saved/stored in a new file upon request upon request.
7. May receive “quit” request from client so that the program terminates.
8. The GUI should thus have several JButtons better with ImageIcon for the sake of aesthetics for submitting different requests by the client

The dissertation may include brief introduction …

tong1 22 Posting Whiz

Palindrome is a popular title for programming training. You may compare a pair of chars in a string, or a pair of words in a String array. Many homeworks are made in this way.
Further more, in Java we may play with all the speaking languages in the world, such as Chinese, Korean, Japanese, Russian, and so on since Java uses Unicode for its char type. I have written a simple program to show the usefulness of both the Java char and the StringBuffer which provides a reverse() method to reverse any string. Please check my code and provide comments.

import java.io.*;
import javax.swing.JOptionPane;
 public class Palindrome{   


 static boolean palindromeCouplet (String s)   {
 	StringBuffer s1 = new StringBuffer(s);
 return ((s.compareTo(new String(s1.reverse()))==0) ? true :false)  ;
 	}	

 public static void main(String[] args) {	
 	while(true){
    String str=JOptionPane.showInputDialog( null,  
	"Type in a word!\nPress cancel to ternimate。",
	"IS A PALINROME",
	JOptionPane.QUESTION_MESSAGE);    
    
	if (str == null) {
	System.out.println("Bey for now");
    	break;
    	} 
JOptionPane.showMessageDialog( null,  
	"Palindrome: " + palindromeCouplet(str),
	str + " IS A PALIDROME? ",
	JOptionPane.INFORMATION_MESSAGE);  
          }
      }   
}
tong1 22 Posting Whiz

You did not show line 28 as error message indicates.
Your result will be always 1 since int division: 1/(e*i) always 0.
You should declare double e = 1.0 instead of int e;
For example, the java method in calculating PI using Lord formula could be:

double Lord(int n) {  // n represents number of iterations/terms
        double pi =1;
        double sqroot;
  for (int i = 3  ; i <n ; i +=2  )
        pi += 1.0/(i*i);
        pi = Math.sqrt(pi*8);
  return pi;
}

The calculation is arried out in terms of double instead of int type.

The java program is presented in terms of class. In C/C++ you may not define a class, but in Java you have to.
Please tell me how to delete my post? I have some posts to be deleted.

tong1 22 Posting Whiz

jon and jemz, I have just completed the program using StringBuffer method: reverse() to check palindrome. My attention is to show the usefullness of StringBuffer

import java.io.*;
import javax.swing.JOptionPane;
 public class Jemz1{   


 static boolean palindromeCouplet (String s)   {
 	StringBuffer s1 = new StringBuffer(s);
 return ((s.compareTo(new String(s1.reverse()))==0) ? true :false)  ;
 	}	

 public static void main(String[] args) {	
 	while(true){
    String str=JOptionPane.showInputDialog( null,  
	"Type in a word!\nPress cancel to ternimate。",
	"IS A PALINROME",
	JOptionPane.QUESTION_MESSAGE);    
    
	if (str == null) {
	System.out.println("Bey for now");
    	break;
    	} 
JOptionPane.showMessageDialog( null,  
	"Palindrome: " + palindromeCouplet(str),
	str + " IS A PALIDROME? ",
	JOptionPane.INFORMATION_MESSAGE);  
          }
      }   
}
tong1 22 Posting Whiz

jemz, the program you are goint to make is working in this way:
The client has to input 4 words,
Then the program checks each individual word to see if it is palindrom.
If so, your outpu seems OK.
Am I right?

tong1 22 Posting Whiz

In this case the program checks the sentence to see if its series of words are palindrome.
The sentence in terms of words:
jemz loves JAVA loves jemz
is palindrome since you see the symmetrical pattern:
jemz to jemz
loves to loves
and
the JAVA to itself JAVA.
The following sentence is not a palindrome: zemz loves JAVA loves aaaa since it is not symmetric.
This is the rule to compare the series of words to see if they are palindrome or not.
Of course, you may modify the rule, e.g. ignoring the the difference in upper/lower case , ignoring interpunction....

tong1 22 Posting Whiz

NormR1 is making a sense.
May I ask you why you use Scanner in Applet?
As far as I understand the Scanner is used for DOS window input. If it is a web application, you may have to create a Textfield instance to receive data a client inputs.

tong1 22 Posting Whiz

After the program has receive 5 words inputed, the i became 5. The the program goes to line 22 : if(words.charAt(forward)!=words.charAt(backward))
and the index outbounds since you have defined the the length (size) of the String array "word" is 5.

Your code is able to check a series of strings a client inputs (in which we determine palindrome in terms of series of words) instead of one string (in which we determine palindrome in terms of characters).
I have modified your code as follows:

import java.io.*;
 public class jemz {
 	
 public static void main(String args[]){
  String []words = new String[5];
  Console console = System.console();
						
			int forward=0;
			int backward=words.length-1;
			int i;
			
			System.out.println("Input 5 words");
						
			for(i=0;i<words.length;i++)
			words[i]=new String(console.readLine("Input the " + (i+1) +" word:\n"));
								
			boolean found=true;
			while(forward<backward)	{
				if (words[forward].compareTo(words[backward]) != 0)	{
					found=false;
					break;					
				}
				
				forward++;
				backward--;								
			}
				if(found)
				System.out.println("palindrome");
		    	else
				System.out.println("Not Palindrome");			
		}
}

The testing output:
Input 5 words
Input the 1 word:
jemz
Input the 2 word:
loves
Input the 3 word:
JAVA
Input the 4 word:
loves
Input the 5 word:
jemz
palindrome

tong1 22 Posting Whiz

NewOrder, your idea is good. You have almostly done.
The problem is found in the line 12:

String Snumber="";

When you at the first time come into the nested while loop:

while(allNumbers.charAt(index)!=',')

it works fine. However, when you use the Snumber at the second time, Snumber holds the previous result that should be removed. In fact, the Snumber finally holds your all ditigs after removing all the comma sign ','.
Solution:
Move String Snumber=""; at line 12 by inserting it after line 31
so that each time shortly after outerloop :

while(index<allNumbers.length())

starts you are able to restart the Snumber, that is, make a new Snumber by the decraration: String Snumber=""

tong1 22 Posting Whiz

No. The other methods are not the main which could be in another class called "driver", to test the class MyPoint.
The following methods you have to implement include:

/*The following nethods are shown in abstract format that you are going to implement. The abstract method has no method body. */
public int getX();
public int getY();
//Perhaps your teacher will ask you create another two methes:
public void setX(int x);
public void setY(int y);
public int distance(MyPoint otherP) //to calculate the distance from this point to another point of the MyPoint type.
public int distance(MyPoint p1, MyPoint p2);// to calculate the distance between two points

Then You should draw the class diagram of UML for the class MyPoint
Finally you may create a driver class MyPointTest where you may create two points ( 0, 0) and ( 10, 30.5) and displays the distance between them. .