- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,我是 Netezza 的新手,我被要求开发自定义 Java 函数并交付 API。
我的问题是我是否可以根据给定的要求提供解决方案。这是要求。
我有一个表,我们将其命名为 Table1。我必须按行读取表并计算不同的值,当我的值有意义时,我必须将其插入到不同的表中。
只是我需要读取多行,计算多个值,当数据有意义时我可以输出它。
所以我的问题是,是否可以在 Netezza 自定义 Java UDTF 函数中读取多行并输出很少的行?
最佳答案
是的,可以读取n行并输出
没有人帮助我,所以我继续构建了该功能,并且运行良好。
三年后,我被要求分享解决方案。我现在不记得要求了,我也离开公司很久了。所以我粘贴了我编写的600行代码,当时我很天真,可能有更好的方法来做到这一点。如果你能理解它,你就会很幸运。
import java.sql.Timestamp;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import org.netezza.ae.Nzae;
import org.netezza.ae.NzaeApi;
import org.netezza.ae.NzaeApiGenerator;
import org.netezza.ae.NzaeDataTypes;
import org.netezza.ae.NzaeException;
import org.netezza.ae.NzaeMetadata;
import org.netezza.ae.NzaeRecord;
import org.netezza.ae.NzaeUtil;
public class viewResolver {
private static final Executor exec = Executors.newCachedThreadPool();
public static final void main(String[] args) {
try {
mainImpl(args);
} catch (Throwable t) {
System.err.println(t.toString());
NzaeUtil.logException(t, "main");
}
}
public static final void mainImpl(String[] args) {
NzaeApiGenerator helper = new NzaeApiGenerator();
while (true) {
final NzaeApi api = helper.getApi(NzaeApi.FUNCTION);
if (api.apiType == NzaeApi.FUNCTION) {
if (!helper.isRemote()) {
run(api.aeFunction);
break;
} else {
Runnable task = new Runnable() {
public void run() {
try {
viewResolver.run(api.aeFunction);
} finally {
api.aeFunction.close();
}
}
};
exec.execute(task);
}
}
}
helper.close();
}
public static int run(Nzae ae) {
try {
int ret = runReal(ae);
ae.done();
return ret;
} catch (NzaeException ex) {
ex.printStackTrace();
ae.userError(ex.getMessage());
ae.done();
throw ex;
} catch (Throwable ex) {
ex.printStackTrace();
ae.userError(ex.toString());
ae.done();
throw new NzaeException(ex.toString());
}
}
static String acc_id = null;
static String rec_id = null;
static String tuner = null;
static String channel = null;
static String show_name = null;
static String tmsId = null;
static String viewing_type = null;
static String event_type = null;
static String channelFamily = null;
static String ruid = null;
static int suid = 0;
static double timeStarted = 0;
static double timeEnded = 0;
static Timestamp datecreated = null;
static double content_start = 0;
static double content_end = 0;
static String prev_acc_id = null;
static String prev_rec_id = null;
static String prev_tuner = null;
static String prev_channel = null;
static String prev_show_name = null;
static String prev_tmsId = null;
static String prev_viewing_type = null;
static String prev_event_type = null;
static String prev_channelFamily = null;
static String prev_ruid = null;
static int prev_suid = 0;
static double prev_timeStarted = 0;
static double prev_timeEnded = 0;
static Timestamp prev_datecreated = null;
static double prev_content_start = 0;
static double prev_content_end = 0;
public static int runReal(Nzae ae) {
double dvr_time_watched = 0;
double vod_time_watched = 0;
double manual_ffx = 0;
double manual_ffr = 0;
boolean end = false;
double tune_duration = 0;
boolean live_DVR_Flag = false;
final NzaeMetadata meta = ae.getMetadata();
NzaeRecord input = null;
boolean firstRecord = true;
validateInput(meta);
while (!end) {
NzaeRecord output = ae.createOutputRecord();
if (true) {
input = ae.next();
if (input == null) {// checks if no more records
end = true;
// returns the final view
if (prev_timeEnded - prev_timeStarted != 0) {// if final view is tune
tune_duration = prev_timeEnded - prev_timeStarted;
output = setOutput(output, prev_acc_id, prev_rec_id, prev_tuner, prev_channel, prev_show_name,
prev_tmsId, prev_viewing_type, prev_event_type, prev_channelFamily, prev_ruid,
prev_suid, prev_timeStarted, prev_timeEnded, prev_datecreated, 0, 0, tune_duration,
manual_ffx, manual_ffr);
ae.outputResult(output);
}
if (vod_time_watched != 0 || dvr_time_watched != 0 || manual_ffr != 0 || manual_ffx != 0) {
if (!prev_event_type.equalsIgnoreCase("DVR_EOE") && dvr_time_watched != 0) {// if DVR
output = setOutput(output, prev_acc_id, prev_rec_id, prev_tuner, prev_channel,
prev_show_name, prev_tmsId, prev_viewing_type, prev_event_type, prev_channelFamily,
prev_ruid, prev_suid, prev_timeStarted, prev_timeEnded, prev_datecreated,
prev_content_start, prev_content_end, dvr_time_watched, manual_ffx, manual_ffr);
ae.outputResult(output);
} else if (!prev_event_type.equalsIgnoreCase("DVR_EOE") && vod_time_watched != 0) {// if VOD
output = setOutput(output, prev_acc_id, prev_rec_id, prev_tuner, prev_channel,
prev_show_name, prev_tmsId, prev_viewing_type, prev_event_type, prev_channelFamily,
prev_ruid, prev_suid, prev_timeStarted, prev_timeEnded, prev_datecreated,
prev_content_start, prev_content_end, vod_time_watched, manual_ffx, manual_ffr);
ae.outputResult(output);
}
}
continue;
} else {// set variables
if (input.getField(0) != null)
acc_id = input.getField(0).toString();
else
acc_id = null;
if (input.getField(1) != null)
rec_id = input.getField(1).toString();
else
rec_id = null;
if (input.getField(2) != null)
tuner = input.getField(2).toString();
else
tuner = null;
if (input.getField(3) != null)
channel = input.getField(3).toString();
else
channel = null;
if (input.getField(4) != null)
show_name = input.getField(4).toString();
else
show_name = null;
if (input.getField(5) != null)
tmsId = input.getField(5).toString();
else
tmsId = null;
if (input.getField(6) != null)
viewing_type = input.getField(6).toString();
else
viewing_type = null;
if (input.getField(7) != null)
event_type = input.getField(7).toString();
else
event_type = null;
if (input.getField(8) != null)
channelFamily = input.getField(8).toString();
else
channelFamily = null;
if (input.getField(9) != null)
ruid = input.getField(9).toString();
else
ruid = null;
if (input.getField(10) != null)
suid = input.getFieldAsNumber(10).intValue();
else
suid = 0;
if (input.getField(11) != null)
timeStarted = input.getFieldAsNumber(11).doubleValue();
else
timeStarted = 0;
if (input.getField(12) != null)
timeEnded = input.getFieldAsNumber(12).doubleValue();
else
timeEnded = 0;
if (input.getField(13) != null)
datecreated = input.getFieldAsTimestamp(13);
else
datecreated = null;
if (input.getField(14) != null)
content_start = input.getFieldAsNumber(14).doubleValue();
else
content_start = 0;
if (input.getField(15) != null)
content_end = input.getFieldAsNumber(15).doubleValue();
else
content_end = 0;
}
}
if (firstRecord) {
prev_acc_id = acc_id;
prev_rec_id = rec_id;
prev_tuner = tuner;
prev_channel = channel;
prev_show_name = show_name;
prev_tmsId = tmsId;
prev_viewing_type = viewing_type;
prev_event_type = event_type;
prev_channelFamily = channelFamily;
prev_ruid = ruid;
prev_suid = suid;
prev_timeStarted = timeStarted;
prev_timeEnded = timeEnded;
prev_datecreated = datecreated;
prev_content_start = content_start;
prev_content_end = content_end;
firstRecord = false;
}
// ********* if acc id or rec id changes
if (prev_acc_id != null && prev_rec_id != null && prev_acc_id != null && prev_rec_id != null) {
if (!prev_acc_id.equalsIgnoreCase(acc_id) || !prev_rec_id.equalsIgnoreCase(rec_id)) {
if (prev_timeEnded - prev_timeStarted != 0) {// if tune
tune_duration = prev_timeEnded - prev_timeStarted;
output = setOutput(output, prev_acc_id, prev_rec_id, prev_tuner, prev_channel, prev_show_name,
prev_tmsId, prev_viewing_type, prev_event_type, prev_channelFamily, prev_ruid,
prev_suid, prev_timeStarted, prev_timeEnded, prev_datecreated, 0, 0, tune_duration,
manual_ffx, manual_ffr);
ae.outputResult(output);
prev_timeEnded = prev_timeStarted = 0;
setPreviousValues();
tune_duration = 0;
manual_ffr = 0;
manual_ffx = 0;
}
if (dvr_time_watched != 0 || manual_ffr != 0 || manual_ffx != 0) {
if (!prev_event_type.equalsIgnoreCase("DVR_EOE")) {// if DVR
output = setOutput(output, prev_acc_id, prev_rec_id, prev_tuner, prev_channel,
prev_show_name, prev_tmsId, prev_viewing_type, prev_event_type, prev_channelFamily,
prev_ruid, prev_suid, prev_timeStarted, prev_timeEnded, prev_datecreated,
prev_content_start, prev_content_end, dvr_time_watched, manual_ffx, manual_ffr);
ae.outputResult(output);
}
dvr_time_watched = 0;
manual_ffr = 0;
manual_ffx = 0;
setPreviousValues();
live_DVR_Flag = false;
}
if (vod_time_watched != 0 || manual_ffr != 0 || manual_ffx != 0) {
if (!prev_event_type.equalsIgnoreCase("DVR_EOE")) {// if VOD
output = setOutput(output, prev_acc_id, prev_rec_id, prev_tuner, prev_channel,
prev_show_name, prev_tmsId, prev_viewing_type, prev_event_type, prev_channelFamily,
prev_ruid, prev_suid, prev_timeStarted, prev_timeEnded, prev_datecreated,
prev_content_start, prev_content_end, vod_time_watched, manual_ffx, manual_ffr);
ae.outputResult(output);
}
vod_time_watched = 0;
manual_ffr = 0;
manual_ffx = 0;
setPreviousValues();
live_DVR_Flag = false;
}
}
}
// ******** special case tune to DVR
if (viewing_type != null && prev_viewing_type != null)
if ((live_DVR_Flag || prev_viewing_type.equalsIgnoreCase("Tune"))
&& viewing_type.equalsIgnoreCase("DvrEvent")) {
if (tmsId != null)
if (!prev_tmsId.equalsIgnoreCase(tmsId)) {
if (live_DVR_Flag) {
// should change the event name to "Live DVR"
if (!prev_event_type.equalsIgnoreCase("DVR_EOE")) {
output = setOutput(output, prev_acc_id, prev_rec_id, prev_tuner, prev_channel,
prev_show_name, prev_tmsId, "LiveDVR", prev_event_type, prev_channelFamily,
prev_ruid, prev_suid, prev_timeStarted, prev_timeEnded, prev_datecreated,
prev_content_start, prev_content_end, dvr_time_watched, manual_ffx,
manual_ffr);
ae.outputResult(output);
}
dvr_time_watched = 0;
manual_ffr = 0;
manual_ffx = 0;
setPreviousValues();
live_DVR_Flag = false;
}
}
if (tmsId != null)
if (prev_tmsId.equalsIgnoreCase(tmsId))
if (event_type != null && content_start != 0 && content_end != 0) {
live_DVR_Flag = true;
// ******* total play time
if (event_type.equalsIgnoreCase("DVR_PLAY") || event_type.equalsIgnoreCase("DVR_PAUSE")) {
dvr_time_watched += (content_end - content_start);
}
// ********* total ffx time
if (event_type.contains("FWD_START") && !event_type.contains("SKIP")) {
manual_ffx += (content_end - content_start);
}
// ********** total ffr time
if (event_type.contains("FWD_END") && !event_type.contains("SKIP")) {
manual_ffr += (content_end - content_start);
}
}
}
// ******** special case DVR to tune
if (viewing_type != null && prev_viewing_type != null)
if ((live_DVR_Flag || prev_viewing_type.equalsIgnoreCase("DvrEvent"))
&& viewing_type.equalsIgnoreCase("Tune")) {
if (tmsId != null)
if (!prev_tmsId.equalsIgnoreCase(tmsId)) {
if (live_DVR_Flag) {
tune_duration = prev_timeEnded - prev_timeStarted;
output = setOutput(output, prev_acc_id, prev_rec_id, prev_tuner, prev_channel,
prev_show_name, prev_tmsId, "LiveDVR", prev_event_type, prev_channelFamily,
prev_ruid, prev_suid, prev_timeStarted, prev_timeEnded, prev_datecreated, 0, 0,
tune_duration, manual_ffx, manual_ffr);
ae.outputResult(output);
prev_timeEnded = prev_timeStarted = 0;
setPreviousValues();
tune_duration = 0;
manual_ffr = 0;
manual_ffx = 0;
live_DVR_Flag = false;
}
}
if (tmsId != null)
if (prev_tmsId.equalsIgnoreCase(tmsId))
if (timeEnded != 0)
prev_timeEnded = timeEnded;
}
// ***** For Tune events
if (prev_viewing_type.equalsIgnoreCase("Tune")) {
if (tmsId != null)
if (!prev_tmsId.equalsIgnoreCase(tmsId)) {
if (prev_timeEnded != 0) {
tune_duration = prev_timeEnded - prev_timeStarted;
output = setOutput(output, prev_acc_id, prev_rec_id, prev_tuner, prev_channel,
prev_show_name, prev_tmsId, prev_viewing_type, prev_event_type, prev_channelFamily,
prev_ruid, prev_suid, prev_timeStarted, prev_timeEnded, prev_datecreated, 0, 0,
tune_duration, manual_ffx, manual_ffr);
ae.outputResult(output);
prev_timeEnded = prev_timeStarted = 0;
setPreviousValues();
tune_duration = 0;
manual_ffr = 0;
manual_ffx = 0;
}
}
if (timeEnded != 0)
prev_timeEnded = timeEnded;
}
// ************ for DVR events
else if (prev_viewing_type.contains("DvrEvent")) {
if (tmsId != null)
if (!prev_tmsId.equalsIgnoreCase(tmsId)) {
if (!prev_event_type.equalsIgnoreCase("DVR_EOE")) {
output = setOutput(output, prev_acc_id, prev_rec_id, prev_tuner, prev_channel,
prev_show_name, prev_tmsId, prev_viewing_type, prev_event_type, prev_channelFamily,
prev_ruid, prev_suid, prev_timeStarted, prev_timeEnded, prev_datecreated,
prev_content_start, prev_content_end, dvr_time_watched, manual_ffx, manual_ffr);
ae.outputResult(output);
}
dvr_time_watched = 0;
manual_ffr = 0;
manual_ffx = 0;
setPreviousValues();
}
if (event_type != null && content_start != 0 && content_end != 0) {
// ******* total play time
if (event_type.equalsIgnoreCase("DVR_PLAY") || event_type.equalsIgnoreCase("DVR_PAUSE")) {
dvr_time_watched += (content_end - content_start);
// play_end = row.getCONTENT_END_EPOCH();
}
// ********* total ffx time
if (event_type.contains("FWD_START") && !event_type.contains("SKIP")) {
manual_ffx += (content_end - content_start);
}
// ********** total ffr time
if (event_type.contains("FWD_END") && !event_type.contains("SKIP")) {
manual_ffr += (content_end - content_start);
}
}
}
// ************ for Vod events
else if (prev_viewing_type.equalsIgnoreCase("VODEvent")) {
if (ruid != null)
if (!prev_ruid.equalsIgnoreCase(ruid)) {
if (!prev_event_type.equalsIgnoreCase("DVR_EOE")) {
output = setOutput(output, prev_acc_id, prev_rec_id, prev_tuner, prev_channel,
prev_show_name, prev_tmsId, prev_viewing_type, prev_event_type, prev_channelFamily,
prev_ruid, prev_suid, prev_timeStarted, prev_timeEnded, prev_datecreated,
prev_content_start, prev_content_end, vod_time_watched, manual_ffx, manual_ffr);
ae.outputResult(output);
}
vod_time_watched = 0;
manual_ffr = 0;
manual_ffx = 0;
setPreviousValues();
}
if (event_type != null && content_start != 0 && content_end != 0) {
// ******* total play time
if (event_type.equalsIgnoreCase("DVR_PLAY") || event_type.equalsIgnoreCase("DVR_PAUSE")) {
vod_time_watched += (content_end - content_start);
// play_end = row.getCONTENT_END_EPOCH();
}
// ********* total ffx time
if (event_type.contains("FWD_START") && !event_type.contains("SKIP")) {
manual_ffx += (content_end - content_start);
}
// ********** total ffr time
if (event_type.contains("FWD_END") && !event_type.contains("SKIP")) {
manual_ffr += (content_end - content_start);
}
}
}
}
return 0;
}
/**
*
*/
private static void setPreviousValues() {
prev_acc_id = acc_id;
prev_rec_id = rec_id;
prev_tuner = tuner;
prev_channel = channel;
prev_show_name = show_name;
prev_tmsId = tmsId;
prev_viewing_type = viewing_type;
prev_event_type = event_type;
prev_channelFamily = channelFamily;
prev_ruid = ruid;
prev_suid = suid;
prev_timeStarted = timeStarted;
prev_timeEnded = timeEnded;
prev_datecreated = datecreated;
prev_content_start = content_start;
prev_content_end = content_end;
}
/**
* @param output
* @param accId
* @param recId
* @param string
* @param channel
* @param showName
* @param tmsId
* @param eventName
* @param eventType
* @param channelFamily
* @param ruid
* @param suid
* @param timeStarted
* @param timeEnded
* @param fieldAsTimestamp2
* @param contentStart
* @param contentEnd
* @param duration
* @param manualFfx
* @param manualFfr
*/
private static NzaeRecord setOutput(NzaeRecord output, String accId, String recId, String string, String channel,
String showName, String tmsId, String eventName, String eventType, String channelFamily, String ruid,
int suid, double timeStarted, double timeEnded, Timestamp fieldAsTimestamp2, double contentStart,
double contentEnd, double duration, double manualFfx, double manualFfr) {
output.setField(0, accId);
output.setField(1, recId);
output.setField(2, string);
output.setField(3, channel);
output.setField(4, showName);
output.setField(5, tmsId);
output.setField(6, eventName);
output.setField(7, eventType);
output.setField(8, channelFamily);
output.setField(9, ruid);
output.setField(10, suid == 0 ? null : suid);
output.setField(11, timeStarted == 0 ? null : timeStarted);
output.setField(12, timeEnded == 0 ? null : timeEnded);
output.setField(13, fieldAsTimestamp2);
output.setField(14, contentStart == 0 ? null : contentStart);
output.setField(15, contentEnd == 0 ? null : contentEnd);
output.setField(16, duration);
output.setField(17, manualFfx);
output.setField(18, manualFfr);
return output;
}
/**
* @param meta
*/
private static void validateInput(NzaeMetadata meta) {
if (meta.getOutputColumnCount() != 19) {
throw new NzaeException("expecting 19 output columns ");
}
if (meta.getInputColumnCount() != 16) {
throw new NzaeException("expecting 16 input columns");
}
if (meta.getInputNzType(0) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(0) != NzaeDataTypes.NZUDSUDX_VARIABLE) {
throw new NzaeException("first input column (Account id hashed) expected to be a string type");
}
if (meta.getInputNzType(1) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(1) != NzaeDataTypes.NZUDSUDX_VARIABLE) {
throw new NzaeException("second input column (Receiver id hashed) expected to be a string type");
}
if (meta.getInputNzType(2) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(2) != NzaeDataTypes.NZUDSUDX_VARIABLE) {
throw new NzaeException("third input column (Tuner) expected to be a string type");
}
if (meta.getInputNzType(3) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(3) != NzaeDataTypes.NZUDSUDX_VARIABLE) {
throw new NzaeException("fourth input column (Channel) expected to be a string type");
}
if (meta.getInputNzType(4) != NzaeDataTypes.NZUDSUDX_NATIONAL_FIXED
&& meta.getInputNzType(4) != NzaeDataTypes.NZUDSUDX_NATIONAL_VARIABLE) {
throw new NzaeException("fifth input column (Show name) expected to be a string type");
}
if (meta.getInputNzType(5) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(5) != NzaeDataTypes.NZUDSUDX_VARIABLE) {
throw new NzaeException("sixth input column (TMS_ID) expected to be a string type");
}
if (meta.getInputNzType(6) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(6) != NzaeDataTypes.NZUDSUDX_VARIABLE) {
throw new NzaeException("seventh input column (Event Name) expected to be a string type");
}
if (meta.getInputNzType(7) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(7) != NzaeDataTypes.NZUDSUDX_VARIABLE) {
throw new NzaeException("eighth input column (Event type) expected to be a string type");
}
if (meta.getInputNzType(8) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(8) != NzaeDataTypes.NZUDSUDX_VARIABLE) {
throw new NzaeException("nineth input column (CHANNEL_FAMILY) expected to be a string type");
}
if (meta.getInputNzType(9) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(9) != NzaeDataTypes.NZUDSUDX_VARIABLE) {
throw new NzaeException("thenth input column (RUID) expected to be a string type");
}
if (meta.getInputNzType(10) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(10) != NzaeDataTypes.NZUDSUDX_INT32) {
throw new NzaeException("eleventh input column (SUID) expected to be a integer type");
}
if (meta.getInputNzType(11) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(11) != NzaeDataTypes.NZUDSUDX_INT64) {
throw new NzaeException("twelfth input column (Start Epoch) expected to be a Big Integer type");
}
if (meta.getInputNzType(12) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(12) != NzaeDataTypes.NZUDSUDX_INT64) {
throw new NzaeException("thirteenth input column (End Epoch) expected to be a Big Integer type");
}
if (meta.getInputNzType(13) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(13) != NzaeDataTypes.NZUDSUDX_TIMESTAMP) {
throw new NzaeException("fourteenth input column (Date created) expected to be a timestamp type");
}
if (meta.getInputNzType(14) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(14) != NzaeDataTypes.NZUDSUDX_INT64) {
throw new NzaeException("fifteenth input column (Content start date) expected to be a Big Integer type");
}
if (meta.getInputNzType(15) != NzaeDataTypes.NZUDSUDX_FIXED
&& meta.getInputNzType(15) != NzaeDataTypes.NZUDSUDX_INT64) {
throw new NzaeException("sixteenth input column (Content end date) expected to be a big Integer type");
}
}
}
关于java - Netezza Java UDTF 自定义函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15707799/
我正在编写一个具有以下签名的 Java 方法。 void Logger(Method method, Object[] args); 如果一个方法(例如 ABC() )调用此方法 Logger,它应该
我是 Java 新手。 我的问题是我的 Java 程序找不到我试图用作的图像文件一个 JButton。 (目前这段代码什么也没做,因为我只是得到了想要的外观第一的)。这是我的主课 代码: packag
好的,今天我在接受采访,我已经编写 Java 代码多年了。采访中说“Java 垃圾收集是一个棘手的问题,我有几个 friend 一直在努力弄清楚。你在这方面做得怎么样?”。她是想骗我吗?还是我的一生都
我的 friend 给了我一个谜语让我解开。它是这样的: There are 100 people. Each one of them, in his turn, does the following
如果我将使用 Java 5 代码的应用程序编译成字节码,生成的 .class 文件是否能够在 Java 1.4 下运行? 如果后者可以工作并且我正在尝试在我的 Java 1.4 应用程序中使用 Jav
有关于why Java doesn't support unsigned types的问题以及一些关于处理无符号类型的问题。我做了一些搜索,似乎 Scala 也不支持无符号数据类型。限制是Java和S
我只是想知道在一个 java 版本中生成的字节码是否可以在其他 java 版本上运行 最佳答案 通常,字节码无需修改即可在 较新 版本的 Java 上运行。它不会在旧版本上运行,除非您使用特殊参数 (
我有一个关于在命令提示符下执行 java 程序的基本问题。 在某些机器上我们需要指定 -cp 。 (类路径)同时执行java程序 (test为java文件名与.class文件存在于同一目录下) jav
我已经阅读 StackOverflow 有一段时间了,现在我才鼓起勇气提出问题。我今年 20 岁,目前在我的家乡(罗马尼亚克卢日-纳波卡)就读 IT 大学。足以介绍:D。 基本上,我有一家提供簿记应用
我有 public JSONObject parseXML(String xml) { JSONObject jsonObject = XML.toJSONObject(xml); r
我已经在 Java 中实现了带有动态类型的简单解释语言。不幸的是我遇到了以下问题。测试时如下代码: def main() { def ks = Map[[1, 2]].keySet()
一直提示输入 1 到 10 的数字 - 结果应将 st、rd、th 和 nd 添加到数字中。编写一个程序,提示用户输入 1 到 10 之间的任意整数,然后以序数形式显示该整数并附加后缀。 public
我有这个 DownloadFile.java 并按预期下载该文件: import java.io.*; import java.net.URL; public class DownloadFile {
我想在 GUI 上添加延迟。我放置了 2 个 for 循环,然后重新绘制了一个标签,但这 2 个 for 循环一个接一个地执行,并且标签被重新绘制到最后一个。 我能做什么? for(int i=0;
我正在对对象 Student 的列表项进行一些测试,但是我更喜欢在 java 类对象中创建硬编码列表,然后从那里提取数据,而不是连接到数据库并在结果集中选择记录。然而,自从我这样做以来已经很长时间了,
我知道对象创建分为三个部分: 声明 实例化 初始化 classA{} classB extends classA{} classA obj = new classB(1,1); 实例化 它必须使用
我有兴趣使用 GPRS 构建车辆跟踪系统。但是,我有一些问题要问以前做过此操作的人: GPRS 是最好的技术吗?人们意识到任何问题吗? 我计划使用 Java/Java EE - 有更好的技术吗? 如果
我可以通过递归方法反转数组,例如:数组={1,2,3,4,5} 数组结果={5,4,3,2,1}但我的结果是相同的数组,我不知道为什么,请帮助我。 public class Recursion { p
有这样的标准方式吗? 包括 Java源代码-测试代码- Ant 或 Maven联合单元持续集成(可能是巡航控制)ClearCase 版本控制工具部署到应用服务器 最后我希望有一个自动构建和集成环境。
我什至不知道这是否可能,我非常怀疑它是否可能,但如果可以,您能告诉我怎么做吗?我只是想知道如何从打印机打印一些文本。 有什么想法吗? 最佳答案 这里有更简单的事情。 import javax.swin
我是一名优秀的程序员,十分优秀!