I am writing a program that get a name and sorts its hash code out I've been given a code fragment that gets the first characters ASCII code but I can't seem to get it to loop the through the entire
string all I get is the first one .Ive tried a for loop,if statment and do while loop
import javax.swing.JOptionPane;
class Student
{
String name;
String course;
int hashTotal;
public Student()
{
}
public Student(String name)
{
this.name = name;
}
public Student(String name,String course)
{
this.name = name;
this.course = course;
}
public int getDetails(String name)
{
if( name != null && name.length() > 0)
{
char letter = name.charAt( 0 ); //get the character from String
int asciiValue = letter; //get the ASCII value of the character
System.out.print("The character '"+ letter);
System.out.println("' has an ASCII value of "+ asciiValue);
}
return hashTotal;
}
public static void main(String [] args)
{
Student s = new Student();
s.getDetails();
}
}