好吧,所以我遇到了对象范围的问题。我使用Jsoup现在这里是代码:Java中变量的范围 - 问题
//Website is /001.shtml, so adding count to the string wouldn't work.
//This is why I have the ifs
if (count < 10)
{
Document site = Jsoup.connect(url + "00" + count).get();
}
else if (count < 100)
{
Document site = Jsoup.connect(url + "0" + count + ".shtml").get();
}
else
{
Document site = Jsoup.connect(url + count + ".shtml").get();
}
好了,所以我创建了一个名为 网站上的文档对象,我需要补充,因为人员如何使网站,零一定量的不问题。但是,当我尝试使用site.select(任何东西),我不能因为对象是在if结构中定义的。
此外,我不能初始化它如果,它不工作,因为我得到了重复的错误抛出。请告诉我有一个解决这个,因为我已经搜索和搜索无济于事,我不想将其余的程序3次放入不同的ifs ...
您应该使用字符串格式。像这样会使输入3个数字:String.format(“%03d”,numberValueHere) – user2272115 2014-11-03 04:32:25
你是什么意思的“它不工作?”请提供错误消息并包含触发错误的最小程序。 – 2014-11-03 05:10:09