0

i am a beginner in java and i have an exercise for homework!i want to find the shortest path in a map! i will do the bfs algorithm! i read the map and i put the chars in a array!After that i want to do bfs in the array so i want to make a queue of elements with two fields, for example a queue that every element is an array [2], in order to put in the first field the array position of the element and in the other one the cost to get there!Any ideas how to do this??Thank you a lot for your time and your help! i tried this but it didn't work!

    Queue  <int []> queue = new LinkedList <int []> ();
    int [] start = {thesi,0};
10
  • What are thesi and start! Commented Jun 5, 2013 at 23:45
  • thesi is the first element of the array in which i want to save the position! Commented Jun 5, 2013 at 23:47
  • start is the first element of the queue! Commented Jun 5, 2013 at 23:47
  • Please improve your post by fixing the formatting and a proper code snippet. Commented Jun 6, 2013 at 0:03
  • 1
    You must import this classes. Use "import" statement before class declaration. Commented Jun 6, 2013 at 0:42

1 Answer 1

2

You need to import java.util.Queue and java.util.LinkedList, the same way you did with java.io.File. See this link for more information.

 import java.util.Queue;
 import java.util.LinkedList;

 import java.io.File;
 import java.io.FileNotFoundException;

 import java.util.Scanner; 

 public class ask1 {

    public static void main(String[] args) {
       // your code...
    }
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.