所以这是我的代码,它显示6张卡,3对,2行.我想要的图像都是相同的大小,而无需手动调整图像大小.响应性确实有效,我使用"img-fluid"作为一个类,当我使用移动设备或更小的浏览器时,它们都具有相同的宽度,但高度仍然是关闭的.
<h1 class="display-4 text-xs-center m-y-3 text-muted" id="speakers">Ice Cream</h1>
<div class="row">
<div class="col-md-6 col-lg-4">
<div class="card"><img alt="Card image cap" class="card-img-top img-fluid" src="img/brownie.jpg" />
<div class="card-block">
<h4 class="card-title">Brownie Delight</h4>
<p class="card-text">Our customer favorite chocolate ice cream jam packed with pieces of brownies and fudge</p>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="card"><img alt="Card image cap" class="card-img-top img-fluid" src="img/butterPecan.jpg" />
<div class="card-block">
<h4 class="card-title">Butter Pecan</h4>
<p class="card-text">Roasted pecans, butter and vanilla come together to make this wonderful ice cream</p>
</div>
</div>
</div>
<div …Run Code Online (Sandbox Code Playgroud) 我很好奇,我想知道是否有办法让JOptionPane的顶部变成不同的颜色,比如红色或橙色.另外我想知道如何更改JOptionPane左侧的图像.我猜这是不可能的,因为它已经是一个从java使用的方法.但我不是专家.
我运行程序,我看到的只是Netbeans下方的空白区域.
起初我以为它没有运行然后我意外地运行了四个程序,Netbeans崩溃了.所以我的第一个问题是:它是一个无限循环,如果是这样,为什么呢?
从我可以看到它是int = 0,0是>=0那么它应该运行的0 + 0......等等,如果int number和int sum都为零,那么这是否意味着程序无法继续,因为它被套牢循环零?但为什么它不会多次显示0的输出而不是空白?
public static void main(String[] args) {
int number = 0;
int sum = 0;
while (number >= 0 || number <= 10) {
sum += number;
number += 3;
System.out.print(" Sum is " + sum);
}
}
Run Code Online (Sandbox Code Playgroud) for (int i = 0; i < s.length(); ++i)
{
if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
{
++array[s.charAt(i) - 'A'];
}
}
Run Code Online (Sandbox Code Playgroud)
我理解For循环.s.length()是26,确切地说是int [26].所以这个循环将发生26次,0-25.如果i,0-25处的Char在或者是AZ之间它将继续进行++array[s.charAt(i) - 'A'];从我看到它每个循环添加一次数组,或者每个循环添加一次数组的值,对于char i的String,所以第一个将是0秒将是2,因为数组从0开始.因此在位置添加数组i -'A'是我感到困惑的地方.
我正在尝试创建一个包含大约100个名字的数组.我希望名称是我选择的而不是随机生成的名称.因此,Array的每个位置都将包含一个名称字符串.有没有比这更简单的方法Array[1] = "name; Array[2] = "name";呢?我的想法是使用for循环从数据文件或文本文件中获取信息,但我不知道如何做到这一点.完成此任务的最简单方法是什么?
这是我到目前为止的代码:
import java.util.*;
public class VoteRecorder
{
// Variables and instance variables
public static String nameCandidatePresident1;
public static String nameCandidatePresident2;
public static String nameCandidateVicePresident1;
public static String nameCandidateVicePresident2;
public static int votesCandidatePresident1;
public static int votesCandidatePresident2;
public static int votesCandidateVicePresident1;
public static int votesCandidateVicePresident2;
private int myVoteForPresident;
private int myVoteForVicePresident;
public VoteRecorder()
{
nameCandidatePresident1 = "null";
nameCandidatePresident2 = "null";
nameCandidateVicePresident1 = "null";
nameCandidateVicePresident2 = "null";
votesCandidatePresident1 = 0;
votesCandidatePresident2 = 0;
votesCandidateVicePresident1 = 0;
votesCandidateVicePresident2 = 0;
myVoteForPresident = 0; …Run Code Online (Sandbox Code Playgroud) 我有一个返回true或false的方法,
public boolean confirmVotes()
{
System.out.println("Your vote for President is:" + getVotes() );
System.out.println("your vote for Vice President is:" + getVotes());
System.out.println("Is this correct? Yes or No?");
Scanner keyboard = new Scanner(System.in);
String answer = keyboard.nextLine();
if (answer.equalsIgnoreCase("Yes"))
return true;
else
return false;
}
Run Code Online (Sandbox Code Playgroud)
我如何在另一种方法中使用此return语句?这就是我想要做的
public void recordVote()
{
if comfirmVotes returns true for X
do this for y
}
Run Code Online (Sandbox Code Playgroud) if (current.leftChild.iData != '+' && current.rightChild.iData != '+')
Run Code Online (Sandbox Code Playgroud)
对于这行代码,我试图检查当前节点的leftChild和当前节点的rightChild是否=='+'或字符加号.如果其中任何一个不=字符+我想执行其他代码.我得到这一行的空指针异常和我用来调用这行代码的方法.iData只是节点内的信息.
java ×7
arrays ×2
class ×2
methods ×2
binary-tree ×1
boolean ×1
char ×1
css ×1
html ×1
image ×1
joptionpane ×1
loops ×1
string ×1
swing ×1
while-loop ×1