Java 如何将一行与一行的txt文件进行比较?

Java 如何将一行与一行的txt文件进行比较?,java,arrays,text,double,line,Java,Arrays,Text,Double,Line,以下是文件: 为了避免任何字符串干扰,我已经将.txt文件中的双精度字符排列到数组列表中 如何将每个双精度一次一行与整个阵列中的一个单独双精度进行比较?您可以强制执行它 take the first element loop through the array return false if the element equals any other element move to the second element loop through the array return false if

以下是文件:

为了避免任何字符串干扰,我已经将.txt文件中的双精度字符排列到数组列表中


如何将每个双精度一次一行与整个阵列中的一个单独双精度进行比较?

您可以强制执行它

take the first element
loop through the array
return false if the element equals any other element
move to the second element
loop through the array
return false if the element equals any other element
move to the third element
...
After the loop is finished, return true

这个算法基本上是蛮力搜索,如果我没记错的话,它不是很有效,但它可以满足你的需要。如果你愿意创建一个BST,你可以减少时间,如果你正在寻找双倍或整数

用线圈?您是否知道
while
for
循环?是的,但如何有效地逐行执行…单个while或for循环通常是O(n),而嵌套for循环则是O(n^2)。