我试图发布无限数量的喜欢,但根据数组中存储的cookie数量来循环cookie和代理.显然,i ++是无法访问的代码.这是什么原因?
public void PostLikes()
{
PostLike postLike = new PostLike();
for (int i =0;i<this.cookies.ToArray().Length;i++)
{
for (int j = 0; ; j++)
{
postLike.PostLike(this.cookies[i], this.importedProxies[i], this.proxyUsernameTextbox, this.proxyPasswordTextbox, this.postsIds[j]);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有这个非常简单的代码片段:
static String getInput() throws IOException{
if(in.ready()){
return in.readLine().trim();
}
System.err.println("Please provide more input in order to execute the program.");
System.exit(0);
return "";
}
Run Code Online (Sandbox Code Playgroud)
据我所知,JVM没有可能在代码末尾执行return语句.但如果我评论这一行,java会抱怨缺少return语句.为什么JVM不能识别System.exit(0)不允许执行任何其他代码,但如果返回不允许执行代码,则会抱怨无法访问的语句?我认为最后的return语句是多余的,可能会让其他开发者感到困惑,为什么java不让我摆脱它呢?
我有以下方法:
char getChar(int I)
{
if (I<65+26) return (char)(I);
switch (I)
{
case 91 : return '?';break;
case 92 : return '#';break;
default : return ' ';
}
}
Run Code Online (Sandbox Code Playgroud)
为什么会出现"无法访问的语句"错误?
这是我的代码。我有一种删除Azure Block Blob的方法。我有一个try / finally块来记录失败的详细信息,否则请继续进行。
我将返回,bool以标识该项目是否已删除。
Visual Studio告诉我return方法末尾的语句不可访问。
public bool Delete(string referenceId)
{
var client = GetBlobClient();
var container = client.GetContainerReference("qwerty");
var blob = container.GetBlockBlobReference(referenceId);
try
{
blob.Delete();
return true;
}
finally
{
Trace.TraceWarning("Delete Blob failed: {0}", referenceId);
}
return false; // <-- THIS LINE.
}
Run Code Online (Sandbox Code Playgroud)
这是为什么?我不必在此方法中返回一些值。
感谢您的见解。
本地一切正常,但出现“无法检测到代码”错误。
这是这段代码:
private string GetRedirectUriForCurrentConfiguration()
{
#if (DEBUG || DebugDev)
return "http://localhost:1855/";
#endif
return "http://172.16.40.39:1855";
}
Run Code Online (Sandbox Code Playgroud)
我在第四行收到“无法访问”消息 return "http://172.16.40.39:1855";
此语句设置正确吗?
我正在尝试在我的源代码中添加一些功能来记录在我执行其余代码(收集wifi和单元数据的总量并通过短信发送)之前至少打了一个电话的事实.当我添加代码以保存至少一个电话时,我最终得到一个错误,指出"无法访问的代码 - 返回startId;" 而且我不确定是什么导致了这个问题.
提前致谢!
消息来源:无法访问代码 - 返回startId;
public class DataCountService extends Service {
String text = "USR;1";
String ERROR = Constants.PREFS_NAME;
private Timer timer = new Timer();
private long period;
private long delay_interval;
public static final String swappedMdn(Context ctx) {
TelephonyManager tm = (TelephonyManager) ctx
.getSystemService(Context.TELEPHONY_SERVICE);
// Extract the phone number from the TelephonyManager instance
String mdn = tm.getLine1Number();
// Insure MDN is 10 characters
if (mdn.length() < 10 || mdn == null)
mdn = "0000000000";
// Extract last …Run Code Online (Sandbox Code Playgroud) 我对Java很新,我在其中一本书中遇到过一两次这个问题.这是一个超级简单的程序,我只是不明白为什么它不起作用.我知道当你使用return时,方法中的任何东西都没有意义.那么这意味着你执行for语句或if语句是一个返回?
我在最新版本的Eclipse中使用Windows 8上的Java 8.
这是我的简单程序:
// Find the sum of 1 through 50 and the average.
class SumAndAverage
{
public static void main(String args[])
{
int sum = 0;
double average = 0;
for(int i = 1; 1 <= 50; i++)
{
sum += i;
}
// the following code is "unreachable"
average = sum / 100;
System.out.println("The sum is: " + sum);
System.out.println("The average is " + average);
}
}
Run Code Online (Sandbox Code Playgroud) 我试图找出一个数字是否为素数.但是我遇到了"检测到无法访问的代码"的错误,我认为这会影响"并非所有代码路径返回值"的错误.错误似乎发生在i ++的for循环中.有人可以帮我吗?
static void Main(string[] args)
{
Console.WriteLine(isPrime(10));
}
public static bool isPrime(int n)
{
for (int i = 2; i < n; i++)
{
if (n % i == 0)
{
return false;
}
return true;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在研究Java中的成绩簿程序,我遇到了"无法访问代码"的问题.如果有人能告诉我是什么导致了这个问题,我会很感激.
static ArrayList<String> assignments = new ArrayList<String>();
static ArrayList<String> grades = new ArrayList<String>();
public static String getAssignment(int a){
return assignments.get(a);
return grades.get(a);
}
Run Code Online (Sandbox Code Playgroud)
它在返回grade.get(a)时给出了错误"无法访问的代码";