我安装了Java JDK8 Eclipse的火星但在有很多与它的问题,所以我卸载它改回JDK7,现在我在我的几个项目中得到一个奇怪的编译错误.我注意到,当我走进,Windows的>首选项> Java的>安装的JRE,有在顶部说,"所选的JRE不支持的1.8 ...租金编译器遵从性级别",但是当一个错误信息我检查编译器合规性级别设置为1.7
好了,所以我决定尝试开始一个新项目,并试图建立它,当一个警告过来,我的工作区达标水平为1.8级......改变工作空间解决了这一问题.新的是可以更改工作区合规性级别,还是应该将项目导入新工作区?
我尝试导入新工作区,同样的问题.所以我在一个新工作区中开始了新项目,将代码复制并粘贴在一个有效的工作中!如果我必须为我想要的每个项目中的每个班级都这样做,那会很烦人.
给定一个字符串,"xyz"是否出现在字符串的中间?为了定义中间,我们将说"xyz"左侧和右侧的字符数必须至少相差一个.这个问题比它看起来更难.
我的解决方案在没有第二个最后一行的情况下工作,除了一个条件:如果str ="xyx"是否可以修改for循环以考虑到这一点......我正在努力理解它为什么不这样做.
我的解决方案确实有效我只是想更好地理解我正在做的事情.我知道我可以将它添加到第一个if语句中,但我想知道为什么没有它它不起作用.
public boolean xyzMiddle(String str) {
for (int i=0;i<str.length()-3;i++) {
if (str.substring(i,i+3).equals("xyz")) {
String front =str.substring(0,i);
String end = str.substring(i+3);
int a =Math.abs(front.length() -end.length());
if (a<=1) return true;
}
}
if (str.equals("xyz")) return true;
return false;
Run Code Online (Sandbox Code Playgroud) 我在尝试计算calc值的行中出现错误
num1 = input("Enter first number:")
num2 = input("Enter second number:")
num3 = input("Enter third number:")
print("Output:")
calc = float((num1 + num2 + num3)/ 2)
print("{0}+{1}+{2})/2 is:{3}".format(num1,num2,num3,calc))
Run Code Online (Sandbox Code Playgroud)
这就是我的感谢,谢谢你的帮助......
num1 = float(input("Enter first number:"))
num2 = float(input("Enter second number:"))
num3 = float(input("Enter third number:"))
print("Output:")
calc = ((num1 + num2 + num3)/ 2)
print("{0}+{1}+{2})/2 is:{3}".format(num1,num2,num3,calc))
Run Code Online (Sandbox Code Playgroud) 我正在用Java编写一个编码问题并且我的解决方案有效,但我看到其他人在他们的博客上发布的另一个解决方案有点短,但我不明白为什么它有效.
问题是:
给定非空字符串和int n,返回一个新字符串,其中索引n处的char已被删除.n的值将是原始字符串中char的有效索引(即n将在
0..str.length()-1包括的范围内).
我的代码(适用于所有条件):
public String missingChar(String str, int n) {
return str.substring(0,n) + str.substring(n+1,str.length());
}
Run Code Online (Sandbox Code Playgroud)
其他有效的代码是:
public String missingChar(String str, int n) {
return str.substring(0, n) + str.substring(n + 1);
}
Run Code Online (Sandbox Code Playgroud)
区别在于第二行的末尾.
我的问题是为什么会str.substring(n+1)产生与之相同的结果str.substring(n+1,str.length())?
假设我有一个包含5个字符串的数组,与该数组相关的是3个整数数组,大小相同.eg`
String a[] = new String[5]
int x[] = new int[5]
int y[] = new int[5]
int z[] = new int[5]
Run Code Online (Sandbox Code Playgroud)
所以a [0],x [0],y [0],z [0]都与同一事物有关.我想找出x []中哪个索引保持最高数字.如果不止一个具有相同的最高数量,那么哪个具有最高数量y []并且如果存在多个具有相同最高数量的那个具有最高数量z [](可以安全地假设没有在z []中具有相同的最大值
我试着尽力解释..
如果只检查前两个条件,这是最好的
for(int i=0;i<a.length;i++)
{
if(x[i]>=maximum){
if(x[i]==maximum)
{
if(y[i]>=maximum)
{
maximum=x[i];
winner=a[i];
maximum=y[i];
}
}
else
{
maximum=x[i];
winner=teams[i];
maximum=y[i];
}
}
Run Code Online (Sandbox Code Playgroud)
所以这是我的新代码
static int compareValues(){
for (int i=0; i<a.length; i++){
int max =0;
int diff = x[i] - x[max];
if (diff == 0){
diff = y[i] - y[max];
} …Run Code Online (Sandbox Code Playgroud) 这是我得到的错误
错误1'System.Array'不包含'guess_word'的定义,并且没有扩展方法'guess_word'接受类型'System.Array'的第一个参数可以找到(你是否缺少using指令或程序集引用?) C:\ Hangman\Jers Hangman Game\Jers Hangman Game\Form1.cs 183 25 Jers Hangman Game
这是我的一些代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Jers_Hangman_Game
{
public partial class Form1 : Form
{
int rndNum = 0;
int wordLength = 0;
int numGuesses = 0;
String tempWordLength = "";
String astericks = "";
int indexOfGuess;
public struct Hangman_words
{
public int no_letters;
public string guess_word, hint;
}
public Hangman_words[] myWords = …Run Code Online (Sandbox Code Playgroud) 这是我的代码的相关部分..
static void salesSlip( String[] day)
{
// for each employee
for (int i = 0; i < salesArray[0].length; i++)
{
int employeeNo = i + 1;
System.out.printf("Employee %d please enter sales details for %s\n", employeeNo, day[i]);
System.out.println("------------------------------------------------");
// for each product chosen call dailySales
System.out.println("Please enter product number or -1 when finished");
int productNo = input.nextInt();
while (productNo != -1)
{
dailySales(productNo, employeeNo);
}
}
}
static void dailySales(int product, int employeeNo)
{
System.out.printf("Enter total value of sales for …Run Code Online (Sandbox Code Playgroud) 它在大屏幕上显示三个图像,这是我想要的,但是当它应该显示2个图像时,它只在小窗口上每行显示一个图像.
<div class="container">
<h2>Pictures of Coffee</h2>
<div class="row">
<div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/04LDEYRW59.jpg" alt=""></div>
<div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/90V03Q5Y60.jpg" alt=""></div>
<div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/O83SF2RB6D.jpg" alt=""></div>
<div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/5JVPSVP7EI.jpg" alt=""></div>
<div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/C5Y10KIIHA.jpg" alt=""></div>
<div class="col-lg-4 col-xs-6 thumbnail"><img src="https://d2lm6fxwu08ot6.cloudfront.net/img-thumbs/960w/YSSFRY5B25.jpg" alt=""></div>
</div>
Run Code Online (Sandbox Code Playgroud)
我认为col-xs-6会分为两个,因为6是12的一半?
谢谢
图像位于 h1 编辑边距中,h1 仅编辑边距左增加图像左侧的边距。尝试增加 i 元素的边距也没有任何作用,在 i 元素上也没有任何作用。
<h1 class="display-4"><i class="fas fa-camera-retro"></i>The Image Gallery</h1>
<p> A bunch of beautiful images that I didn't take</p>
Run Code Online (Sandbox Code Playgroud)
我想增加相机图标和文本之间的间距。