String userAge;
while(true){
System.out.println("Enter user Age");
userAge = scInput.nextLine();
if(tryParseInt(userAge)){
return userInfo[row][1] = userAge;
break;
}else{
System.out.println("Please Enter an integer.");
}
}
Run Code Online (Sandbox Code Playgroud)
初学者,名字是里根.
我的问题是我的代码因为"break;"而无法编译.它说这是一个无法访问的代码.我觉得我在这里做错了,我几乎可以肯定它与变量类型有关..不知道怎么做.这是一种要求用户年龄的方法.
我的目标是通过我的tryParseInt()方法传递一个字符串来测试并确保输入数据是一个整数,但保留它作为字符串类型变量.
我正在创建一个多维String数组来存储用户的数据.就是名字; 年龄; 地点.
IsSaveNew是类型的bool?
CoverLetterId类型int?
if (coverLetter.IsSaveNew ?? true || coverLetter.CoverLetterId == null)
Run Code Online (Sandbox Code Playgroud)
coverLetter.CoverLetterId == null.此声明在visual studio(2012)中标记为无法访问.
但如果IsSaveNew是假的,那么它将达到第二个条件.为什么Visual Studio这么说?
做一些c#循环和if语句.获取for循环中无法访问代码的突出显示.我不太清楚这一点.
public bool checkTime()
{
// Read values back from Json file
var serializedList = File.ReadAllText(@filePathTimes);
// getting a list of LockTime objects
List<LockTime> deserializedList = (List<LockTime>)JsonConvert.DeserializeObject(serializedList, typeof(List<LockTime>));
if (deserializedList.Count != 0)
{
// Grab whatever data you want from this list to store somewhere, such as a list of all Start and End integers.
List<DateTime> intStartList = deserializedList.Select(entry => entry.Start).ToList();
List<DateTime> intEndList = deserializedList.Select(entry => entry.End).ToList();
//Then I do a foreach loop to go through every value in the …Run Code Online (Sandbox Code Playgroud) 由于某种原因,以下代码无法访问.我无法理解为什么我的代码永远不会到达,因为这是一个简单的模式匹配.这里是:
type Occurrences = List[(Char, Int)]
def combinations(occurrences: Occurrences): List[Occurrences] = occurrences match{
case Nil => Nil
case List() => List()
case x => List(x)
case x::xs => combinations(List((x._1,x._2 - 1))) ::: combinations(xs)
}
Run Code Online (Sandbox Code Playgroud)
该算法旨在提取给定列表的所有子列表.
由于我是从一个java岛上来的,我觉得为什么编译器不会警告无法访问的代码,例如:
int main(int argc, char** argV)
{
std::list<int> lst = {1,2,3,4};
return 0;
std::cout << "Done!!!" << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我的问题:
为什么我可以编译带有2个返回的代码?
我的编译器是gcc for c ++ 11,在Windows上,代码块
这是我的代码,我不喜欢警告。
currentFlag.inc()正在发出警告:无法访问的代码,如果(currentFlag == 1)正在发出警告:未使用的等于表达式
private fun processGather() {
TODO("process Gather implemented")
currentFlag.inc()
if (currentFlag == 1) {
this.binding.ivStep1.setImageDrawable(AppCompatResources.getDrawable(this, R.drawable.step2))
}
}
Run Code Online (Sandbox Code Playgroud) 这是我的代码,我得到一个无法访问的语句错误,但我不知道为什么.
public boolean Boardload(String[] args) throws Exception
{
Robot robot = new Robot();
Color color3 = new Color(114, 46, 33);
Color color4 = new Color(180, 0, 0);
{
Rectangle rectangle = new Rectangle(0, 0, 1365, 770);
{
while(false)
{
BufferedImage image = robot.createScreenCapture(rectangle);
search: for(int x = 0; x < rectangle.getWidth(); x++)
{
for(int y = 0; y < rectangle.getHeight(); y++)
{
if(image.getRGB(x, y) == color3.getRGB())
{
return true;
}
}
}
}
}
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
确切的错误是:
java:68: …Run Code Online (Sandbox Code Playgroud) 我正在为我的AP计算机科学课创建一个tic tac toe游戏,到目前为止它运行没有错误,或者错误已通过简单的修复解决.但是,当我向程序添加if语句时,它会不断显示一条错误,指出"无法访问的代码".我仍然无法确定原因或如何解决此问题.
我使用"魔方"设置游戏,每行和对角线设置为一个变量,最多加15,这是程序确定胜利者的方式.
此if语句中出现错误:
if(topx == 15 || middlex == 15 || bottomx == 15 || leftx == 15 || centerx == 15 || rightx == 15 || diag1x == 15 || diag2x == 15){ String XWIN =("X wins!"); g.drawString(XWIN,60,50); }
上面的if语句属于x播放器,但o播放器的if语句也有相同的错误.
整个代码如下所示(我为可怜的笔记道歉)
public void paint(Graphics g){
this.setSize(450, 430); //sets the game screen size.
//initial directions
System.out.println("Player 1 (x) goes first. there are 9 boxes available.");
System.out.println("The numbers correspond to the boxes respectively.");
System.out.println("1 being top left, 2 being …Run Code Online (Sandbox Code Playgroud) 我正在尝试用C#编写程序来查明数字是否为素数.我使用前两个if语句来挑出许多选项,然后我试图在最后的else语句中嵌套一个循环,它告诉我有"检测到无法访问的代码".
public static bool primeNumber ()
{
Console.Write ("Please enter a number to see if it is a prime number: ");
int num = int.Parse (Console.ReadLine ());
if (num % 2 == 0)
return false;
else if (num % 5 == 0)
return false;
else {
for (int i = 3; i < num / 2; i += 2)
{
if (num % i == 0)
return false;
else
return true;
}
}
}
Run Code Online (Sandbox Code Playgroud) 我在打字稿文件中收到警告“检测到无法访问的代码”。运行 Firebase 事务后没有任何效果。这是交易代码:
// Create Firestore reference
let pointsRef = 'Users/'+this.user.uid;
var pointsDocRef = this.afs.doc(pointsRef).ref;
return this.afs.firestore.runTransaction((transaction) => {
return transaction.get(pointsDocRef).then((ptsDoc) => {
if(!ptsDoc.exists){
throw "Document does not exist!"
}
var newPtsScore = ptsDoc.data().points - 20;
transaction.update(pointsDocRef, { points: newPtsScore });
});
}).then(() => {
console.log('Point count successfully decremented for new item');
// Close dialog
this.dialog.closeAll();
}).catch(function(error) {console.log('Transaction failed: ', error);});
console.log('Hey there!'); <-- "UNREACHABLE CODE DETECTED"
Run Code Online (Sandbox Code Playgroud)
javascript unreachable-code firebase angular google-cloud-firestore
unreachable-code ×10
c# ×3
java ×3
while-loop ×2
.net ×1
android ×1
angular ×1
applet ×1
awt ×1
c++ ×1
codeblocks ×1
firebase ×1
for-loop ×1
if-statement ×1
javascript ×1
kotlin ×1
loops ×1
scala ×1
winforms ×1