我已在我的数据库中以加密格式存储用户密码.然而,现在,当用户想要登录,并试图把他们的原始密码的代码始终与存储在数据库中的加密版本的进入(原)密码,导致登录失败.
请告诉我如何将输入的(原始)密码与存储在数据库中的加密密码进行比较.
我做了一个Yahtzee游戏,玩家掷5个骰子并使用随机数生成器来确定骰子值.当我在模拟器上运行时,骰子似乎是随机的,但出于某种原因,当我在某些手机上运行它时,玩家会继续为许多骰子获得相同的值:太经常让它成为巧合.例如,如果一个骰子上出现一个骰子,则通常会出现3个或4个其他骰子.使问题难以找到的原因是它不一致:偶尔投掷是正常的.我使用以下代码确定所有5个骰子的随机数:
public void randomDize(){
int randSpot;
for(int i = 0; i < 5; i++){
Random randomGenerator = new Random();
randSpot = randomGenerator.nextInt(6);
if(DieSet[i]== 0){
DieVal[i]=randSpot;
imageButtons[i].setBackgroundResource(imageRes[randSpot]);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我做了一个计数器应用程序,当用户在控制台中输入"stop"时,它使用线程来中断计数.我仔细检查了我的代码,我看不出问题.我是新手,所以任何人都可以看看这个.
import java.util.Scanner;
public class CounterInterruptApp
{
public static void main(String[] args)
{
new CounterInterruptApp().start();
}
public void start()
{
Thread counter = new Counter(); //Instantiate the counter thread.
counter.start(); //Start the counter thread.
Scanner scanner = new Scanner(System.in);
String s = "";
while(!s.equals("stop")); //Wait for the user to enter stop.
s=scanner.next();
counter.interrupt(); //Interrupt the counter thread.
}
}
public class Counter extends Thread //Extend Thread for the use of the Thread Interface.
{
public void run()//Run method. This is …Run Code Online (Sandbox Code Playgroud) 我想检查另一个字符串中是否存在字符串,然后执行相应的操作.做这个的最好方式是什么?
例如; 如果字符串'europe'出现在'europeisthebest'中,那就做点什么吧.
if ( isIn('europe', 'europeisthebest') == true){
//do something
}
Run Code Online (Sandbox Code Playgroud)
非常感谢!我很感谢你所有的答案和花在帮助上的时间.
我正在我的Intro Java编程课程中工作,并且想知道我在一个if声明中是否有一个快捷方式.
基本上,我的程序收到一张扑克牌的双字符缩写并返回完整的卡片名称(即"QS"返回"黑桃皇后".)
现在我的问题是:当我if为编号的卡2-10 编写语句时,我是否需要为每个数字单独声明,还是可以将它们组合在一个if语句中?
检查我的代码所在的位置IS AN INTEGER(显然不是Java表示法.)这是我的代码片段,用于澄清:
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter the card notation: ");
String x = in.nextLine();
if (x.substring(0,1).equals("A")){
System.out.print("Ace");
}
else if(x.substring(0,1) IS AN INTEGER) <= 10)){ // question is about this line
System.out.print(x);
}
else{
System.out.println("Error.");
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试像Java中的命令一样实现String:
public static void main(String[] args) {
String command = "System.out.println("hello word");";
...
}
Run Code Online (Sandbox Code Playgroud)
我需要将命令String转换为命令行,以便在控制台中执行输出"hello word".我想使用这项技术来改进代码:
SimpleDateFormat sdf = new SimpleDateFormat("MMMM");
String month = sdf.format(calIndex.getTime());
switch (month) {
case "January":
leaveDetailCLateLEarly.february += 10;
break; }
...
Run Code Online (Sandbox Code Playgroud)
以上是相当冗长的.我想写一些更短的东西:
String command = "leaveDetailCLateLEarly."+ month + "+= 10"
Run Code Online (Sandbox Code Playgroud)
其中leaveDetailCLateLEarly是一个对象并具有12个月的属性.(即1月,2月等...)然后我有命令字符串:'leaveDetailCLateLEarly.month = 10',其中月份值可以改变(1月,2月,3月,......).项目运行时,String将转换为命令行以实现所需的功能.
我有一个简单的 Jackson 解析器,它应该返回我的值,但我只得到null值。任何想法将不胜感激?
示例 Json 数据:
{"a":"ab","b":"cd","c":"cd","d":"de","e":"ef","f":"fg"}
Run Code Online (Sandbox Code Playgroud)
代码:
var jfactory = new JsonFactory()
var jParser : JsonParser = jfactory.createJsonParser(new File(outputDir + "/" + "myDic.json"))
while (jParser.nextToken() != JsonToken.END_OBJECT) {
var k = jParser.getCurrentName();
jParser.nextToken();
var v = jParser.getText();
println(k +"---" + v)
phoneDict.put(k,v);
i = i + 1;
println(phoneDict.size)
var t = readLine("Dict Done ?")
}
Run Code Online (Sandbox Code Playgroud)
输出:
null---null
1
Dict Done ?
null---null
1
Dict Done ?
null---null
1
Dict Done ?
null---null
1
Dict Done ?
Run Code Online (Sandbox Code Playgroud) 我仍然是新编码的新手.我正在尝试使用填充了"x"元素的数组,并且需要找到一系列数字.参数采用数组,最小数量和最大数量.最终结果需要包括它们之间的最小值,最大值和数字.这是我所说的一个例子:
The starting array:[2, 8, 7, 3, 4]
Min value: 1
Max value: 5
End result: [2, 3, 4]
Run Code Online (Sandbox Code Playgroud)
我希望这不会让人感到困惑,而且我有点理解它.
我的代码是这样的:
public static int[] range(int[] a, int low, int high)
{
int[] rangeArray = new int[0];
for (int i = low; i <= high; i++)
{
if (low >= a.length && high <= a.length)
{
rangeArray[i] = a[i];
}
}
return rangeArray;
}
Run Code Online (Sandbox Code Playgroud) 我想显示一个小部件,用于显示动画加载的gif,而另一个函数(pthread)计算任务。
我试图用一个QThread类对我的窗口小部件进行子类化,并实现了run()我称之为method的方法show()。但是,我的窗口小部件GUI冻结了。
如何启动单独处理GUI的小部件?