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};
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...
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.