您是否知道任何ord与chrJava中的Python 相同的函数.
关于它们的Python文档.
我手动经验但似乎有很多错误.这将需要使用的Strings不只是char.想我会看到是否有预先构建的功能.
谢谢
基本上我正在制作一个基于文本的"游戏"(不是一个游戏,更多的是一种提高基本java技能和逻辑的方法).但是,作为其中的一部分,我希望有一个计时器.它会减少我希望从变量到0的时间.现在,我已经看到了一些使用gui执行此操作的方法,但是,有没有一种方法可以在没有gui/jframe等的情况下执行此操作.
所以,我想知道的是.你可以在不使用gui/jframe的情况下从x到0进行倒计时.如果是这样,你会怎么做?
谢谢,一旦我有一些想法将编辑进展.
编辑
// Start timer
Runnable r = new TimerEg(gameLength);
new Thread(r).start();
Run Code Online (Sandbox Code Playgroud)
以上是我如何调用线程/计时器
public static void main(int count) {
Run Code Online (Sandbox Code Playgroud)
如果我在TimerEg类中有这个,那么计时器符合.但是,当我在另一个线程中编译main时.

现在,我完全错过了解线程以及这将如何工作?还是有什么我想念的?
错误:
constructor TimerEg in class TimerEg cannot be applied to given types;
required: no arguments; found int; reason: actual and formal arguments differ in length
Run Code Online (Sandbox Code Playgroud)
在线发现 Runnable r = new TimerEg(gameLength);
有人能帮我把这个Python脚本转换成Java吗?
这是代码
theHex = input("Hex: ").split()
theShift = int(input("Shift: "))
result = ""
for i in range (len(theHex)):
result += (hex((int(theHex[i],16) + theShift))).split('x')[1] + " "
print(result)
Run Code Online (Sandbox Code Playgroud)
这就是我所拥有的
System.out.print("Please enter the hex: ");
String theHex = BIO.getString();
String[] theHexArray = theHex.split(" ");
System.out.print("Please enter the value to shift by: ");
int theShift = BIO.getInt();
String result[] = null;
for( int i = 0 ; i < theHex.length() ; i++ ){
//result += (hex((int(theHex[i],16) + theShift))).split('x')[1] + " "
}
toText(result[]); …Run Code Online (Sandbox Code Playgroud) 我有这个。“详细说明俱乐部在用户输入的任意两个给定日期之间放映的所有电影。例如,俱乐部成员必须能够为查询参数输入开始日期和结束日期”
现在,我将如何进行用户输入?我能想到的唯一方法是使用 php 或带有 html 表单的东西来获取值,然后将它们作为变量提交到查询中。然而,这不是所需要的。那么,这是如何完成的,以便查询要求值?或者你不能?
到目前为止,我的查询看起来像这样。
SELECT film.title, film.desc, show.sdate, show.fdate
FROM film
INNER JOIN show
ON film.ID=show.filmID
WHERE sdate = '&userstart' AND fdate = '&userend'
Run Code Online (Sandbox Code Playgroud)
我如何处理用户输入?另外,查询是否正确?我没有办法测试,我只有一个设计而不是一个实现。
非常感谢
编辑:使用 Windows 系统,MS SQL Server。
我需要能够从页面上的下拉框中读取并从中获取值,仅此而已(目前)我目前拥有此代码。
JavaScript
function main(input)
{
value = getValue();
alert(value);
}
function getValue()
{
var len = document.form1.values.length
var chosen = ""
for (var i = 0; i < len; i++) {
if (document.form1.values[i].selected) {
chosen = document.form1.values[i].value
}
}
return chosen;
}
Run Code Online (Sandbox Code Playgroud)
HTML
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Shopping Cart</title>
<link href="style.css" title="Style" rel="stylesheet" type="text/css">
<script src="javascript/js.js" type="text/javascript"></script>
</head>
<!-- Start content -->
<body>
<!-- Wrapper to hold all content in -->
<div id="wrapper">
<!-- Top header, …Run Code Online (Sandbox Code Playgroud) 我们还没有涵盖ArrayLists只有Arrays和2D数组.我需要做的是能够从另一个类的ArrayList中读取.主要目的是在for循环中读取它们并使用存储在其中的值来显示项目.但是,我已经制作了这个快速程序来测试它并不断收到此错误
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at Main.Main(Main.java:14)
Run Code Online (Sandbox Code Playgroud)
这是我的代码
import java.util.ArrayList;
public class Main
{
public static void Main()
{
System.out.println("Test");
ArrayList <Objects> xcoords = new ArrayList<Objects>();
for( int x = 1 ; x < xcoords.size() ; x++ )
{
System.out.println(xcoords.get(x));
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后是ArrayList所在的类
import java.util.ArrayList;
public class Objects
{
public void xco()
{
ArrayList xcoords = new ArrayList();
//X coords
//Destroyable
xcoords.add(5);
xcoords.add(25);
xcoords.add(5);
xcoords.add(5);
xcoords.add(25);
xcoords.add(5);
//Static Walls
xcoords.add(600);
xcoords.add(400);
xcoords.add(600);
}
} …Run Code Online (Sandbox Code Playgroud) 在Java中创建Integer类型的arraylist时,默认值是什么?我需要检查arraylist是否已满并且我将获得数组的大小然后获取最后一个索引的值并检查它是否是默认值.
有没有更好的办法?什么是默认值?
希望有道理.干杯
int size = a.size();
int last = a.get(size);
if( last == null )
{
return true;
}else{
return false;
}
Run Code Online (Sandbox Code Playgroud)
编辑;
是否有可能创建一个具有最大大小的ArrayList,以阻止它动态扩展?当你创建一个ArrayList并使用size()时会返回实际大小或arraylist中的元素数量吗?当这样做以创建最大尺寸时,默认值是否为空?
public boolean isFull()
{
int size = a.size();
int last = 0;
try{
last = a.get(size-1);
}catch (Exception e){
}
if( last == null )
{
return true;
}else{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我目前有这个,它看起来怎么样?这现在有意义吗?
我已经对此持续了一段时间,我相信这有一个简单的答案.会发生什么,我删除一个名为"付款"的div然后再动态创建它,以便我可以添加它.然后重复,因为需要添加到其中的信息发生变化.
到目前为止,我已经进行了调整.
function clearPage()
{
var d = document.getElementById("contain");
var d_nested = document.getElementById("payment");
var deleteNode = d.removeChild(d_nested);
}
function createPayment()
{
payment = document.createElement("div");
payment.id = "mine";
document.getElementById("contain").appendChild(payment);
}
function printOnPage()
{
var x = names.length;
for( var i = 0 ; i < x ; i++ )
{
var para = document.createElement("p");
var paymentDiv = document.getElementById("payment");
paymentDiv.appendChild(para);
var txtName = document.createTextNode("Item: ");
para.appendChild(txtName);
var txtNameArray = document.createTextNode(names[i]);
para.appendChild(txtNameArray);
var txtQty = document.createTextNode(" Qty: ");
para.appendChild(txtQty);
var txtQtyArray = document.createTextNode(qty[i]); …Run Code Online (Sandbox Code Playgroud)