javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

ERROR:
non-static method isPrime(int) cannot be referenced from a static context

As the error says, You cannot call a non-static method inside a static method.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Check the API.

p.addActionListener(new gameinit());

The JFrame class doesn't have such method: addActionListener.
Then search the API some more to find which elements accept an ActionListener (Buttons and such)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

In order for this method to execute:

public void actionPerformed(ActionEvent e)
		{
			Izzy.hittable();
			Izzy.movement();

			if(rar == 'T')
			{
				System.out.print("Sky High(Grand Nuave)");
			}
		}

You need to add its listener to a component. The methods in the 'KeyListen' are executed because you do this:

p.addKeyListener(new KeyListen());

When you want the actionPerformed method to execute?
Also since it it the gameinit class that implements the listener, it is an instance of that class that you will add:

someComponent.addActionListener(new gameinit());
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Well since you found the number you know one of the occurrences of the number.
Assume this:
You are looking for '3'

1 2 3 3 3 4 5

And you find the position of the "Red" 3. So all the others 3s will be either left or right from the position you found. Of course your algorithm might find this:

1 2 3 3 3 4 5

or this:

1 2 3 3 3 4 5

You need to search the neighbor positions to see if the target is there. Maybe another while loop before you return.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can check the API to see if there is a way to get the data from the table.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

java extension are file.java

perhaps you should try to use eclipse to make your java codes

This thread has already been solved and you added no additional information.
Also using eclipse will not solve the problem but it will make it bigger because the user will not have learned a thing about java. Now he knows that compiled files end with .class and he knows how to execute them. And I assume he knows how to set the classpath.
If he had gone with eclipse, he would be running the code without knowing how .class files work or how to run a single java file. That is not learning.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Because you only have ONE tempPerson object. You have the same instance of it:

tempPerson.setPerson(tempName, tempAddress, tempBirthDate);

System.out.println(tempPerson.getLastName()); // <-- OK here

student.add(new Student(tempPerson, tempCompDate, gpa, credits));

System.out.println(student.get(counter).getPerson().getLastName());

The last system.out at the above code prints the name correctly because it is the last one read from the loop. Then when you loop again you replace the name in the tempPerson object, and you put the latest in the list. Then you print what you read and you see correct results.
But
You put in the Student object the tempPerson. So when you do this: tempPerson.setPerson(tempName, tempAddress, tempBirthDate); you change the value of tempPerson.
Since in java all the objects are passed by reference ALL the student objects you created have the SAME tempPerson instance.
So when you change the tempPerson, it changes that tempPerson in all the Students that are in the ArrayList.

Inside the loop you create a new Student each time before you put it in the list: student.add(new Student(tempPerson, tempCompDate, gpa, credits)); Do the same for the rest:

tempName = new ....();
tempAddress = new ....();
tempBirthDate = new ....();
tempPerson = new ....();
tempCompDate = new ...();

tempName.setName(firstName, middleInitial, lastName, suffix);
tempAddress.setAddress(addLine1, addLine2, city, state, zip);
tempBirthDate.setDate(BirthDayDateInt, BirthDayMontInt, BirthDayYearInt);
tempPerson.setPerson(tempName, tempAddress, tempBirthDate);
tempCompDate.setDate(CompletionDayInt, CompletionMonthInt, CompletionYearInt);
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I don't know. Have you checked the API for Treemap?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try run it without the .class extension:
> java Hi

Then post the error that you will get :)

darkagn commented: snap +3
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You need to use java.util.Date, not java.sql.Date.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Yes, but you didn't say what the error is. The code seems fine. What is your problem?

Also you should post a few lines of the file you are reading.
Also check the API for the class: Scanner:
http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html
You will find it at the link: java.util at the left column.

Its method: nextLine returns the entire line, so I assume that the file you are reading is like:

lastName
firstName
middleInitial
..
..


..
lastName
firstName
middleInitial

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

All right brother. I got wad r u trying to say. One more problem bro. How do you choose an element from the JList( single click ) and when i click a button called Loan, it will appear a jOptionPane tellin me if i want to borow the book.

I would suggest, before asking such questions, first to check the java API:
java API
javax.swing
JList
getSelectedValue()

When you click the button, inside the actionPerformed, call that method (getSelectedValue) I assume that you have added "Patron" objects inside the list. If that method returns something other than null, means that you have selected something at the list. Then you can cast it to "Patron" and you are ready to do whatever you want.
Also if you need to cast it to some other of the "child" classes then I have showed you a way with the "instanceOf" keyword:

Patron patron = (Patron)list.getSelectedValue();

//either use the methods of the super class, or do some more casting:
if (patron instanceOf UnderGraduate) {
     UnderGraduate unGrad = (UnderGraduate)patron;
} else if (...) { ... }

I don't quite remember the "instanceOf " syntax so you might want to double check it by searching for it at the internet.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You don't need the newPatron object. In the if statements you will only have one instance. You will not have an instance of the super class. Only of child classes. The way you have it in the if statements, you put some data in:
newPatron: newPatron.setName(txtPatronName.getText()); and some in newGraduatePatron: newGraduatePatron.setAdvisor(txtGradAdvisorName.getText()); Then which one will you put in the list. Remember, the chilcd class have access to the super methods:

public class Father {
   public String name;
   public String getName() {
      return name;
   }
    public void setName(String name) {
        this.name = name;
    }
}

public class Child1 extends Father {
   public int age;
   public int getAge() {
      return age;
   }
    public void setAge(int age) {
        this.age = age;
    }
}

// SO:
{
    Child1 ch1 = new Child1();
     ch1.[B]setName[/B]("Name");
     ch1.[B]setAge[/B](11);
}

In your code you can have this:

private void GetPatronDetails()
	{
		if(GradPatron.isSelected())
		{
			newGraduatePatron.setName(txtPatronName.getText());
			newGraduatePatron.setAddress(txtPatronAdd.getText());
			newGraduatePatron.setPhoneNo(txtPatronTphone.getText());
			newGraduatePatron.setPatronID(txtPatronNum.getText());
			newGraduatePatron.setAdvisor(txtGradAdvisorName.getText());
			newGraduatePatron.setGradProgram(txtGraduateProg.getText());

[B]// add to list the newGraduatePatron[/B]
		}
		else
			if(UnderGradPatron.isSelected())
			{
......
[B]// add to list the newUnderGradPatron[/B]
			}
			else
				if(FacPatron.isSelected())
			    {
		
.....
[B]// add to list the newFacultyPatron[/B]
			    }	
	}

Or you can have the above method return the patron:

private Patron GetPatronDetails()
	{
		if(GradPatron.isSelected())
		{
			// get the data from the fields
    return newGraduatePatron;
		}
		else
			if(UnderGradPatron.isSelected())
			{
							// get the data from the fields
return newUnderGradPatron;
			}
			else
				if(FacPatron.isSelected())
			    {
						// get the data from the fields
return newFacultyPatron;
			    }	
	}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Isn't this suppose to throw an ArrayIndexOutOfBounds Exception?:

names[names.length] = ...

names's length is 1 java.lang.ArrayIndexOutOfBoundsException: [B]1[/B]

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Inside the actionPerformed you can try this:

private void actionPerformed(ActionEvent event) {
  // assuming that you have a list globally of type Patron (the super class)

  if (radioButton1 is checked) {
     // get from the desired fields the data and create a new instance:
     [B]newUnderGradPatron[/B]= new [B]UnderGradPatron[/B]();
    // set the values from the fields
    // add to the same list

  } else if (radioButton2 is checked) {
     // get from the desired fields the data and create a new instance:
     [B]newGraduatePatron[/B]= new [B]GraduatePatron[/B]();
    // set the values from the fields
    // add to the same list

  } else if (radioButton3 is checked) {
     // get from the desired fields the data and create a new instance:
     [B]newFacultyPatron[/B]= new [B]FacultyPatron[/B]();
    // set the values from the fields
    // add to the same list
  }
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The phone[][] is null. That is why you are getting the exception.

And no this:

String phone[][] = { {"A", "B","C"},
       {"D", "E", "F"},
       {"G","H", "I"},
       {"J", "K", "L"},
       {"M", "N", "O"},
       {"P", "R", "S"},
       {"T", "U", "V"},
       {"W", "X", "Y"} };

Is not the same phone array as the one you are trying to access. The one you created is locally in the constructor. Your other methods can't see it.
when you are calling it form your code:

System.out.println("Element in [0][2]is: "+ phone[0][2]);

You are calling the one globally declared. You need to create that one in your constructor:

String [][] phone = null;

public TelePhone_Number_Word_Generator()
    {
       phone  = new String[8][3];
    
      phone[0][0] = "A";
      ...
      ...
    }
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I didn't quite realize your problem but here are some suggestions.

You can have one class with all the info and you can have one field indicating what type it is. You can have if-statements that check that field (type of patron) and display the data you want.


If you want to put different objects that extend the same class in the same list then here is an example:

public class Father {
    public Father() {

    }
    public String nameOfTheClass() {
        return "[ Father ]";
    }
}

public class Child1 extends Father {
    public Child1() {

    }
    public String nameOfTheClass() {
        return "[ Child 1 ]";
    }
}

public class Child2 extends Father {
    public Child2() {

    }
    public String nameOfTheClass() {
        return "[ Child 2 ]";
    }
}

Then the following code has 2 versions depending if you are using version 1.4 or newer.

Father f = new Father();
        Child1 ch1 = new Child1();
        Child2 ch2 = new Child2();

        [B]// You can add them to vector because they are all of type "Father[/B]"
        Vector<Father> v2 = new Vector<Father>();
        v2.add(f);
        v2.add(ch1);
        v2.add(ch2);

        [B]// here you get them from the vector and put them into "Father" objects[/B]
        Father f1 = v2.get(0);
        Father f2 = v2.get(1);
        Father f3 = v2.get(2);

       [B]// But when you print them[/B]
        System.out.println(f1.nameOfTheClass());
        System.out.println(f2.nameOfTheClass());
        System.out.println(f3.nameOfTheClass());

        [B]// The f2,f3 are actually "Child1", "Child2". You have access to the data of the Child1, Child2 classes but of course you can call only the methods …
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

We need to see more code

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I am not familiar with the classes of the javax.swing you are using but my experience tells me this:

Firstly, I assume that the method you use to add the book to the list takes as argument an Object class. That is OK because your Book extends the Object class and all of its methods.
But since it takes an Object as parameter it doesn't know the methods you have declared in your Book for displaying data.

But wait the Object class has a method that all classes inherit. That method is automatically called to display the data. But since you didn't override it, it returns what the original method returns: The name of the class followed by its hashCode value:
Book@b0f13d.

You know what is the method I am talking about don't you? It is the toString method.

Try this:
In a separate class create a Book instance in the main method, do this and execute that code:

public static void main(String [] args) {
   Book newBook = new Book (IDNum,Title,Author,Publishr,CatNumPublicationYr,returnDate,BookStat,ISBN);
  
  System.out.println(newBook);
}

Then go to the Book class and do this:

class Book {

   public String toString() {
      return "This book: " + title + " was written by "+ author;
   }
}

And execute the above code again and see what happens.


Also the same applies when you put objects inside a List (Vector, ArrayList) and you try to print that list. It prints …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Because this:
123456789123
is not an int, it's a long.

It is a classic mistake when you try to use a big number. If you check the API you will see how big an int can be.

What value does this represent? Because we use int or long when we intend to do calculations with the fields.
For example if you want to save a phone number make it as String not an int.
If it is some key or id then you can put it to be long.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

These lines are incorrect:

GetBookDetails();
newBook = new Book (IDNum, Title,Author,Publishr,CatNumPublicationYr,returnDate,BookStat,ISBN);

with the GetBookDetails you get all the date from the gui, but when you call the "new Book" you "erase" the previous object and replace it with the new one. At the next lines the newBook doesn't have any of the values read because you did newBook = new Book and you created a new one with the default values that are declared at the class.

I think that this is what you want:

newBook = new Book (IDNum, Title,Author,Publishr,CatNumPublicationYr,returnDate,BookStat,ISBN);

GetBookDetails();
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you run this code you will see that '==' doesn't work:

public static void main(String [] args) {
        String s1 = new String("aa");
        String s2 = new String("aa");
        
        System.out.println(s1==s2); // false
        System.out.println(s1.equals(s2)); // true
    }

The '==' checks if they are the same object and the equals their value. String is an object and you should treat it as such. Meaning that for objects if you want to check if they are equal use the "equals" method.

If you create an object of your own with private attributes/properties and you want to compare 2 of those then you should use the equals method. But since you wrote that class, you must implement/override the equals method.

Especially if you want to put that object in a List(Vector, ArrayList). The methods that they have for searching in the list, use the "equals" method of the object they contain. If you put java objects then that's ok because they already have that method. But for your own objects, your class must implement/override the equals method.

There is a code with action listener at the java gui where at the action performed method we use this '==' instead of equals.

private JButton butt = new JButton("Click here.");

public void actionPerformed(ActionEvent e) {
  Object src = e.getSource();
  if (src[B]==[/B]butt) {
     // button was clicked
  }
}

We use the '==' in this case because that method (getSource) returns the same instance of the object (the butt instance itselfm not …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

At the validation I believe that the seconds should until 59. For the hours you 23, 59. Why not the same for seconds.

For the extract when you multiply and then do a mod, you will get 0.

123 * 100 = 12300
12300 mod 100 = 0
12300/100 = 123

mod returns what is left from the division:
9 = 2 * 4 + 1
9 mod 2 = 1
9 mod 4 = 1

This is the time: 125345 (12:53:45)
In java when you divide an int with an int you will get an int:

125345/100 = 1253
1253 * 100 = 125300

125345/100.0 = 1253.45

So when you divide by 100 you have:
1253
The time is:
125345
1253
Think how can you get the seconds.

THEN:
1253 / 100 =
12
Now how can you get the minutes.

The 12 is the hours

tom.t commented: Very helpful. Thank you. +0
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I want to prevent unathorized users to access directly using URL in my application

When the user logs in, do you put that user in the session?

String username;
String password;

// check the database to see if the user is valid.
if (yes) {
  request.getSession().setAttribute("USER",username);
}

When the user logs out do you do this:

request.getSession().setAttribute("USER",null);

And my suggestion would be to put this check in all of your pages:

String username = (String)request.getSession().getAttribute("USER");
if (username==null) {
  // unauthorized user
  // redirect to log in page
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Actually I understood that the objective was to monitor how many times a word appeared.
I would suggest sth like this:

String word;
Vector linesAppeared;

And the size of the vector would be how many times the word appeared.

You must notice that from the code given, the words that the OP wants to search for are predetermined. And originally he was searching for the frequency of their appearance.
The reason I didn't want to go into the OO solution was the novice level of the poster, and I wanted to stick to the solution that he thought.


Thanks for your congrats remark
Of course if

BestJewSinceJC commented: actually agreed - the extra class may be more confusing than anything +4
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
int lineCount = 0;
while(scanner.hasNext()) {
     lineCount++;
     System.out.println("Line "+lineCount+" is: "+scanner.next());
}

So have a Vector for each word
When the word is found, add to the word's Vector the line number.

Vector vIf = new Vector();

....
// inside the while loop
if (line.equals("if")) {
   Freq[1] = Freq[1] + 1;
   vIf.add(lineCount);
}

You don't know how many are the lines that contain the "if". So you have a vector and whenever an "if" is found you add to the vector the line number (count).

for (int i=0;i<vIf.size;i++) {
     System.out.println("The 'if' found at line: "+vIf.get(i));
}

Meaning that you don't need the Freq array because the size of the vector would be the numbers the 'if' appeared.


But you might need an array of vectors to make your program more advanced:

Vector [] vArray = new Vector[13];
for (int i=0;i<vArray.length;i++) { // vArray is an array
   vArray[i] = new Vector(); // vArray[i] is a vector. You need to initialize each element
}

and in your if statements you can skip the Freq. Instead of increasing it, replace it with the array of Vectors

if (s.equalsIgnoreCase("a") )
   //Freq[0] = Freq[0] + 1;
    vArray[0].add(count);
else if ( s.equalsIgnoreCase("if") )
   //Freq[1] = Freq[1] + 1;
    vArray[1].add(count);

Now the size of each Vector tells you how many times a word was found and their elements tell you at which lines they appeared.


PS.: This is my 1500th post! Yeeeees.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You know very well that this is not the way to declare variables:

int firstnumber = 1,2,3,4,5,6,7,8,9,10,11,12,13;
int secondnumber = 1,2,3,4;

If you can't fix this, don't go any further.

This is how you read a number

System.out.println("Enter firstnum: ");
int fnum = QueenOfDaimond .nextInt();
System.out.println("Firstnum: "+fnum);

Do the same for the second number.

Use if statements to check the numbers:

if (fnum is in range) {
   if (second num is in range) {
       // calculate the ouput
    } else {
        // print second num not in range
    }
} else {
 // print fnum is not in range
}

If you don't know cards then:
1: Ace
2: two
....
11: Jack
12: Queen
13: King

As for the colors:
Hearts, Spade, ... and I don't know the english names of the rest
You can do any type of mapping for those.

As for the if and switch statements, that is up to you.
You should know how to write a simple if statements or how to use the '>' or the '<' operator, as well as the '&&' and the '||'.
If not, I can not teach you these thinks, you need to study for yourself.

Also search for the sun tutorials to find how to work on a switch. You should be able to find an example

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The ones between the "" are strings and they will be printed they way they are. Surely you have written the Hello World program:

System.out.println([B]"Hello World"[/B]);

System.out.println([B]"Row
number "[/B] + loops + [B]" "[/B] + loops + [B]" x "[/B] + num + [B]" = "[/B] + result);

The loops, num ,results are variables. Did you try to run it and see what it prints?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What do you mean by "X".
Maybe this:

number " + loops + " " + loops + " [B]x[/B] " + num + " = " + result);
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Be more careful!!.
You missed the postcode. Count your arguments.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

java.util.Vector

Vector<Integer> v = new Vector<Integer>();

v.add(1);
v.add(2);
v.add(3);

for (int i=0;i<v.size();i++) {
   int num = v.get(i);
   System.out.println(num);
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
int count = 0;
while(scanner.hasNext()) {
     count++;
     System.out.println("Line "+count+" is: "scanner.next());
}

You might need a Vector because you don't know how many lines are the ones for each word.
So have a Vector for each word
When the word is found, add to the word's Vector the line number.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

That is what I mean, but why don't you run it and see what happens. If you get correct results, it means that you understood correct.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I think you need to remove the '0' from the first number:

personalList[0] = new Personal("Paul "," White ", [B]0[/B]74078L , "51 Princes Street", "North Shields", "Tyne and Wear", 7852384379L);
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all run this code:

while(scanner.hasNext()) {
     System.out.println(scanner.next());
}

The name of the method is pretty self explanatory:
Whenever you call it it returns the next word.
In your while loop you keep calling it again and again inside the loop so every time you get the next word. This doesn't compare the same word:

if( input.next() == "a") // this will return a word
					Freq[0] = Freq[0] + 1;
				else
					if( input.next() == "if") // this will return a different word from the previous one
						Freq[1] = Freq[1] + 1;

Also use the equals method to compare objects such as the String object: if ( s.equals("a") ) { .. }

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you want to find a specific word from within a file, another way to do it would be to use Scanner's next() method, then use String.equals to see if they match.

Actually my solution is not correct. If a word contains the argument then it will return that it found it, even though it is not a whole word but only a part of it.

In order for my solution to work, the OP would have to use the .split(" ") method to "break" the line and then use the equals method the way you described.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

JavaAddict,
sorry, to disturb you again. How can I build without having rate? e.g.

rt=d (rate multiplied by time = distance)

Thank you in advance

MJ

Your question doesn't make sense.

int distance = 80 * time;
// or
int rate = 80;
int time = ...;
int distance = rate * time;
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

the time multiplied by 80

It's not that difficult. Multiply time by 80 and put it in the distance

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all check the Scanner API. You found a code and you didn't think to check the API.

Now, there is the nextLine method that reads the next line of the file. Combine it with the has.. methods to read the entire file:

while (scanner.hasNextLine() ) {
   String line = scanner.nextLine();

// check if the line contains the words you want
int i = line.indexOf("if");
// if i==-1 then not found
}

You can store the entire file in a Vector(add each line to a vector as the loop runs) and then loop through the vector to find the words you are looking for. Or you can check the line as you read it.
You might want to use the method: String.indexOf(String s)
It will return -1 if the argument is not found (check the String API)


OR
For a more sophisticated way, use regular expressions and patterns with these methods:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html#hasNext(java.lang.String)
or
findInLine

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Sorry for the double posting but a better way would be:

public class feetInches
{
public static final int FEET_TO_INCHES = 12;
public static final double INCHES_TO_FEET = 1.0/12.0;

public static void main(String [] args)
{
int feet = 5;
int inches = feet * FEET_TO_INCHES ;

System.out.println(feet + " feet is " + inches);
}
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
public class feetInches
{
public static void main(String [] args)
{
int feet = 5;
int feetToInches = 12;
int inches = feet * feetToInches ;

System.out.println(feet + " feet is " + inches);
}
}

If you want the user to enter input then search this forum for the Scanner class

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Don't use these methods:
ye.getYear()
They are deprecated.
Instead use the java.util.Calendar
And use the get method

Calendar rightNow = Calendar.getInstance();
rightNow.get(Calendar.MONTH);

This will return the month. Read the static fields of the API

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

We know that it doesn't run. The code I told you to add was so that we can see what are the values of the variables so we can figure out what is the problem.
You changed the code and instead of posting the results we keep repeating that it doesn't work.

You complained about printing null.
After you added the code, what does it print?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Im not sure I understand what you mean.

I can print the the String s1 with the set from inside the loop but what I want to do is produce all the possible combinations of the result of s1. Then print them to the screen.

I dont understand what you mean by this

import java.io.*;
import java.util.*;
import java.lang.*;

public class gaelan3

{
  static int size;
  static int count;
  static char[] charArray;

  public static void main(String[] args) throws IOException
  {



	String s1= null;

	/*System.out.println("Please enter letters for anagram problem to be solved. Thankyou");

	BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
	String s = read.readLine();
	String input = s;
	*/

	String validChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	Random r = new Random();


	for(int i=1; i<10; i++)
			  {  char randomChar = validChars.charAt(r.nextInt(validChars.length()));
			      s1 = Character.toString(randomChar);

			     System.out.println("s1: "+s1);

			  }



	String input = s1;
			     System.out.println("input: "+input);
    size = input.length();
    count = 0;
    charArray = new char[size];
    for (int j = 0; j < size; j++)
   	  charArray[j] = input.charAt(j);
    doAnagram(size);
  }
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try to print the value s1 from inside the loop.
Then print the value of s1 and input after the assignment.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Why don't you post the code that compiles

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The compiler error should be enough to help you fix this. Read it carefully.
Focus on the part: "Cannot resolve symbol s1"

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
public static float average(short [] grades) {
  // calculate the average using a for loop
}

And to call it after you have your array created and entered values in it:

short [] grades = .... ;
..
..

float avrg = average(grades);
BestJewSinceJC commented: Congrats on 200th solved.. :) (Well marked solved anyway) +4
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have 3 methods that accept a:
short [] as argument and return the min, the max, and the average.

And next time use code tags. Press the button that says (CODE) when you create a new post

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Your question has been answered:

http://www.daniweb.com/forums/thread232053.html

If this answers your question give a positive rep to BestJewSinceJC