- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有 editText1、editText2 和 EditText3 .用户需要在此区域写入个人信息。当他们按下保存按钮时, editText1、editText2 和 EditText3 必须保存。他们应该在他们想要的时候找到他们写的东西。但是当我尝试保存 其中 3 个(editText1、editText2 和 EditText3) ,这不会发生。 我可以只保存editText1 .或者我可以在 editText1 中保存 3 个空格区域。例如,我在editText1“你好”,在editText2“听”,在editText3“伙计们”中写道,我正在保存这个,当我在保存区域打开时,我可以看到3次“听”。其他不保存。 你能帮助我吗?我应该改变什么?
主要 Activity :
public class MainActivity extends AppCompatActivity {
static ArrayList<Bitmap> newImage;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.add_new, menu);
return super.onCreateOptionsMenu(menu);
}
@Override //Menüyü seçersek ne olacak onu belirler.
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.add_new) {
Intent intent = new Intent(getApplicationContext(), Main2Activity.class);
intent.putExtra("info", "new"); //Bu satırda amaç eğer yeni bir resimmi yoksa eski resimmi görentülenmek isteniyor onu anlamak
startActivity(intent);
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView listView = (ListView) findViewById(R.id.listView);
//Databaseden çektiğimiz dataları kaydedeceğimiz bir arraylist oluşturalım ve listview ile bağlayalım
final ArrayList<String> newName = new ArrayList<String>();
final ArrayList<String> newName2 = new ArrayList<String>();
final ArrayList<String> newName3 = new ArrayList<String>();
newImage = new ArrayList<Bitmap>();
ArrayAdapter arrayAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,newName);
listView.setAdapter(arrayAdapter);
//uygulama ilk açıldığında database'de kayıtlı bir şey varmı bakmasını istiyoruz aşağıdaki aşamalarda
try {
Main2Activity.database = this.openOrCreateDatabase("Yeni", MODE_PRIVATE, null);
Main2Activity.database.execSQL("CREATE TABLE IF NOT EXISTS yeni (name VARCHAR, name2 VARCHAR, name3 VARCHAR, image BLOB)");
Cursor cursor = Main2Activity.database.rawQuery("SELECT * FROM yeni", null); //Data çekmek için cursoru kullanıyoruz
int nameIx = cursor.getColumnIndex("name");
int name2Ix = cursor.getColumnIndex("name2");
int name3Ix = cursor.getColumnIndex("name3");
int imageIx = cursor.getColumnIndex("image");
cursor.moveToFirst();
while (cursor != null) {
newName.add(cursor.getString(nameIx)); //Kullanıcının girdği ismi newName'in içine ekle
newName2.add(cursor.getString(name2Ix));
newName3.add(cursor.getString(name3Ix));
byte[] byteArray = cursor.getBlob((imageIx));
Bitmap image = BitmapFactory.decodeByteArray(byteArray,0,byteArray.length);
newImage.add(image); //newImage'in içine ekle diyoruz
cursor.moveToNext();
arrayAdapter.notifyDataSetChanged();//Eğer bir datayı değiştirdiysek hemen güncelleyen bir konut
}
} catch (Exception e) {
}
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent (getApplicationContext(), Main2Activity.class);
intent.putExtra("info", "old");
intent.putExtra("name", newName.get(position));
intent.putExtra("name2", newName2.get(position));
intent.putExtra("name3", newName3.get(position));
intent.putExtra("position", position);
startActivity(intent);
}
});
}
}
public class Main2Activity extends AppCompatActivity {
ImageView imageView; //imageView'i heryerde tanımladık
EditText editText;
EditText editText2;
EditText editText3;
static SQLiteDatabase database; //Buraya yazdığımız database'e MainActivity'den de ulaşabileceğiz çünkü statik yazdık
Bitmap selectedImage; //seçilen resmi kaydetmek için burada bunu tanımladık
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
imageView = (ImageView) findViewById(R.id.imageView); //layouttaki imageView'i tanımladık
editText = (EditText) findViewById(R.id.editText);
editText2 = (EditText) findViewById(R.id.editText2);
editText3 = (EditText) findViewById(R.id.editText3);
Button button = (Button) findViewById(R.id.button); //Buton tanımladık
Intent intent = getIntent();
String info = intent.getStringExtra("info"); //MainActivity'deki 28. satırla bağlantılı
if (info.equalsIgnoreCase("new")) {
Bitmap background = BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.dede); //Kullanıcı resim seçerkenki aşama
imageView.setImageBitmap(background);
button.setVisibility(View.VISIBLE); //Eğer yeni eklenecekse görünür yap
editText.setText(""); //Bu satır eğer daha önceden bir şey yazdıysak onun orada kalmamasını bize boş yazma yeri açmasını sağlıyor
editText2.setText("");
editText3.setText("");
} else {
String name = intent.getStringExtra("name");
editText.setText(name);
String name2 = intent.getStringExtra("name2");
editText2.setText(name2);
String name3 = intent.getStringExtra("name3");
editText3.setText(name3);
int position = intent.getIntExtra("position", 0);
imageView.setImageBitmap(MainActivity.newImage.get(position));
button.setVisibility(View.INVISIBLE); //Eskiyse gösterme
}
}
//Resim koyma yerine tıklandığında olacaklar
public void select (View view) {
if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, 2);
} else {
Intent intent = new Intent (Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); //Kullanıcının medyasına eriş diyoruz
startActivityForResult(intent,1);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == 2) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Intent intent = new Intent (Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); //Kullanıcının medyasına eriş diyoruz
startActivityForResult(intent,1);
}
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
//Yukarıdaki medyaya erişime izin verildiyse resim seçme yeri
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1 && resultCode == RESULT_OK && data!= null) {
Uri image = data.getData();
//try ve catch ın içine aldık bu olayı çünkü bi sorun çıkarsa burda uygulama hata vermesin.
try {
selectedImage = MediaStore.Images.Media.getBitmap(this.getContentResolver(), image);
imageView.setImageBitmap(selectedImage); //imageView'e burda ulaşmak için koyduk
} catch (IOException e) {
e.printStackTrace();
}
}
super.onActivityResult(requestCode, resultCode, data);
}
// Kaydetme butonuna tıklandığında olacaklar
public void save (View view) {
String newName = editText.getText().toString(); //Kullanıcının kardettiği isme bu şekilde ulaştık
String newName2 = editText2.getText().toString();
String newName3 = editText3.getText().toString();
//image'ler bytearray şeklinde kaydedilir!!!!!!!!!!
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); //selectedImage'i compress etmeliyiz kaydetme aşamalarından biri
selectedImage.compress(Bitmap.CompressFormat.PNG,50,outputStream); //bu şekilde ziplemiş olduk resmi
byte[] byteArray = outputStream.toByteArray(); //Bu outpuSteam'i al array'e çevir dedik! ve resmimiz kaydedilebilir oldu
try { //Tüm bu alttaki aşamalarda kullanıcının girdiği isim ve resmi database'imize işlemiş olduk!
database = this.openOrCreateDatabase("Yeni", MODE_PRIVATE, null);
database.execSQL("CREATE TABLE IF NOT EXISTS yeni (name VARCHAR, image BLOB)");
String sqlString = "INSERT INTO yeni (name, image) VALUES (?, ?, ?, ?)";
SQLiteStatement statement =database.compileStatement(sqlString);
statement.bindString(1,newName);
statement.bindString(3,newName2);
statement.bindString(4,newName3);
statement.bindBlob(2,byteArray);
statement.execute();
} catch (Exception e) {
e.printStackTrace();
}
Intent intent = new Intent(getApplicationContext(), MainActivity.class); //kaydet'e bastığında anasayfaya yönlendirilsin
startActivity(intent);
}
}
最佳答案
问题 1 是您尝试定义同一个表,但有 4 列(在 onCreate
的 MainActivity
方法中),然后使用 2 列(在 save
的 Main2Activity
方法中),第二个不会将表创建为它已经被创建了,所以看起来 4 列版本将存在(如果它不存在并且表被创建,那么每当您返回 MainActivity
作为两列(name2
和name3
) 将不存在并导致在尝试 int name2Ix = cursor.getColumnIndex("name2");
时找不到列。
一个 第二期是您尝试插入 2 个值,但将 4 个值作为参数给出,即 INSERT INTO yeni (name,image) ....
2 个值 VALUES(?, ?, ? ,?)
4个论据。
一个 第三期是您没有检测到插入的成功或失败,而只是假设它会起作用(当它不起作用时)。在 SQLiteDatabase 方法周围使用 try/catch 也不是一个好主意,因为它们通常会处理许多情况,并且只会在出现严重错误时崩溃(并且您想要崩溃)。
一个 第四期是您可以单击保存按钮(假设您在布局中使用了android:onClick="save"
),selectedImage
很可能是空的。
一个 第五期是用 Main2Activity
完成后你尝试开始MainActivity
,这将开始另一个 Activity ,而不是您通过完成 Main2Activity
返回它.目前,这对您有利,因为 ListView 列出了新插入的行。但是,您最终会获得大量 Activity ,并且点击后退按钮将逐步返回 Activity 堆栈,并且会非常困惑。
修复第5个问题,即完成Main2Activty
介绍了 第6期那就是 List 没有刷新,它保持在插入新行之前的状态。
修复第 6 个问题需要更改许多代码,但最终您通过覆盖 onResume
来刷新列表通过重建 List 的源(清除 ArrayList 然后将所有元素添加到其中)的方法。
第 4 期的临时修复。
忽略第一个问题,这不会导致问题,因为看起来首先创建了具有 4 列的表(当然是在测试中)。
并且最初也忽略了第 2 和第 3 期。但是使用:-
if (info.equalsIgnoreCase("new")) { // UNCHANGED
Bitmap background = BitmapFactory.decodeResource(
getApplicationContext().getResources(),
android.R.drawable.ic_dialog_alert //<<<< Use a stock Android image for testing
); //Kullanıcı resim seçerkenki aşama
selectedImage = background; //<<<< ADDED to overcome null pointer exception
imageView.setImageBitmap(background); //<<<< UNCHANGED
//........ rest of the code
Main2Activity
的
onCreate
方法和输入在 3 个 EditText 中的测试、测试和测试,然后单击按钮会导致返回到 MainActivity 但没有显示任何内容。但是,日志显示预期的
E/SQLiteLog: (1) 4 values for 2 columns
:-
06-03 22:13:09.895 2647-2647/yeni.yeni E/SQLiteLog: (1) 4 values for 2 columns
06-03 22:13:09.895 2647-2647/yeni.yeni W/System.err: android.database.sqlite.SQLiteException: 4 values for 2 columns (code 1): , while compiling: INSERT INTO yeni (name, image) VALUES (?, ?, ?, ?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:994)
at yeni.yeni.Main2Activity.save(Main2Activity.java:145)
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:384)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
public void save (View view) {
String newName = editText.getText().toString(); //Kullanıcının kardettiği isme bu şekilde ulaştık
String newName2 = editText2.getText().toString();
String newName3 = editText3.getText().toString();
//image'ler bytearray şeklinde kaydedilir!!!!!!!!!!
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); //selectedImage'i compress etmeliyiz kaydetme aşamalarından biri
selectedImage.compress(Bitmap.CompressFormat.PNG,50,outputStream); //bu şekilde ziplemiş olduk resmi
byte[] byteArray = outputStream.toByteArray(); //Bu outpuSteam'i al array'e çevir dedik! ve resmimiz kaydedilebilir oldu
ContentValues cv = new ContentValues();
cv.put("name",newName);
cv.put("name2",newName2);
cv.put("name3",newName3);
cv.put("image",byteArray);
long new_row_id = database.insert("yeni",null,cv);
//<<<< ADDED TO ISSUE TOAST WITH THE RESULT
if (new_row_id > 0) {
Toast.makeText(this,"Row Insereted.",Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this,"Row NOT Inserted",Toast.LENGTH_SHORT).show();
}
/*
try { //Tüm bu alttaki aşamalarda kullanıcının girdiği isim ve resmi database'imize işlemiş olduk!
Log.d("SAVE","Attempting OPEN Or CREATE DATABASE");
database = this.openOrCreateDatabase("Yeni", MODE_PRIVATE, null);
Log.d("SAVE","Attempting CREATE OF TABLE yeni");
database.execSQL("CREATE TABLE IF NOT EXISTS yeni (name VARCHAR, image BLOB)");
String sqlString = "INSERT INTO yeni (name, image) VALUES (?, ?, ?, ?)";
SQLiteStatement statement =database.compileStatement(sqlString);
statement.bindString(1,newName);
statement.bindString(3,newName2);
statement.bindString(4,newName3);
statement.bindBlob(2,byteArray);
Log.d("SAVE","Attempting EXECUTION of the SQL INSERT using :- " + statement.toString());
statement.execute();
} catch (Exception e) {
e.printStackTrace();
}
*/
Intent intent = new Intent(getApplicationContext(), MainActivity.class); //kaydet'e bastığında anasayfaya yönlendirilsin
startActivity(intent);
//this.finish(); //<<<< Should not start a parent activity you should return to it by finishing the child activity
}
onResume
刷新列表
中的方法MainActivity
public class MainActivity extends AppCompatActivity {
static ArrayList<Bitmap> newImage;
ArrayList<String> nameList;
ArrayList<String> name2List;
ArrayList<String> name3List;
ArrayAdapter<String> arrayadpater;
ListView listView;
Button addbutton; //<<<< Instead of menu for my convenience
//<<<<<<<<<< Code Commented out for convenience of using button >>>>>>>>>
/*
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.add_new, menu);
return super.onCreateOptionsMenu(menu);
}
@Override //Menüyü seçersek ne olacak onu belirler.
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.add_new) {
Intent intent = new Intent(getApplicationContext(), Main2Activity.class);
intent.putExtra("info", "new"); //Bu satırda amaç eğer yeni bir resimmi yoksa eski resimmi görentülenmek isteniyor onu anlamak
startActivity(intent);
}
return super.onOptionsItemSelected(item);
}
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = (ListView) findViewById(R.id.listview); //<<<< CHANGED as declared as class variable
//<<<<<<<<<< Code below for the conveince of using a button instead of Menu >>>>>>>>>>
addbutton = (Button) findViewById(R.id.addnew);
addbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), Main2Activity.class);
intent.putExtra("info", "new"); //Bu satırda amaç eğer yeni bir resimmi yoksa eski resimmi görentülenmek isteniyor onu anlamak
startActivity(intent);
}
});
//<<<<<<<<<< End of code for Button handling >>>>>>>>>>
setupListView();
//<<<<<<<<<< NOTE commented out Code >>>>>>>>>>
/*
//Databaseden çektiğimiz dataları kaydedeceğimiz bir arraylist oluşturalım ve listview ile bağlayalım
final ArrayList<String> newName = new ArrayList<String>();
final ArrayList<String> newName2 = new ArrayList<String>();
final ArrayList<String> newName3 = new ArrayList<String>();
newImage = new ArrayList<Bitmap>();
ArrayAdapter arrayAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,newName);
listView.setAdapter(arrayAdapter);
//uygulama ilk açıldığında database'de kayıtlı bir şey varmı bakmasını istiyoruz aşağıdaki aşamalarda
try {
Main2Activity.database = this.openOrCreateDatabase("Yeni", MODE_PRIVATE, null);
Main2Activity.database.execSQL("CREATE TABLE IF NOT EXISTS yeni (name VARCHAR, name2 VARCHAR, name3 VARCHAR, image BLOB)");
Cursor cursor = Main2Activity.database.rawQuery("SELECT * FROM yeni", null); //Data çekmek için cursoru kullanıyoruz
int nameIx = cursor.getColumnIndex("name");
int name2Ix = cursor.getColumnIndex("name2");
int name3Ix = cursor.getColumnIndex("name3");
int imageIx = cursor.getColumnIndex("image");
cursor.moveToFirst();
while (cursor != null) {
newName.add(cursor.getString(nameIx)); //Kullanıcının girdği ismi newName'in içine ekle
newName2.add(cursor.getString(name2Ix));
newName3.add(cursor.getString(name3Ix));
byte[] byteArray = cursor.getBlob((imageIx));
Bitmap image = BitmapFactory.decodeByteArray(byteArray,0,byteArray.length);
newImage.add(image); //newImage'in içine ekle diyoruz
cursor.moveToNext();
arrayAdapter.notifyDataSetChanged();//Eğer bir datayı değiştirdiysek hemen güncelleyen bir konut
}
} catch (Exception e) {
}
*/
}
//<<<< ADDED to handle return from child >>>>
@Override
public void onResume() {
super.onResume();
setupListView();
}
//<<<< ADDED to utilise a single refreshable ListView
private void setupListView() {
getListsFromDatabase();
if (arrayadpater == null) {
arrayadpater = new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,nameList);
listView.setAdapter(arrayadpater);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent (getApplicationContext(), Main2Activity.class);
intent.putExtra("info", "old");
intent.putExtra("name", nameList.get(position));
intent.putExtra("name2", name2List.get(position));
intent.putExtra("name3", name3List.get(position));
intent.putExtra("position", position);
startActivity(intent);
}
});
} else {
arrayadpater.notifyDataSetChanged();
}
}
//<<<< Added to build/rebuild the Arraylist's used by the ListView
private void getListsFromDatabase() {
// Get the database (and set the databse for Main2Acticity)
SQLiteDatabase db = openOrCreateDatabase(
"Yeni",
MODE_PRIVATE,
null
);
db.execSQL("CREATE TABLE IF NOT EXISTS yeni (name VARCHAR, name2 VARCHAR, name3 VARCHAR, image BLOB)");
Main2Activity.database = db;
// Initialise or clear the array lists
if (nameList == null) {
nameList = new ArrayList<>();
} else {
nameList.clear();
}
if (name2List == null) {
name2List = new ArrayList<>();
} else {
name2List.clear();
}
if (name3List == null) {
name3List = new ArrayList<>();
} else {
name3List.clear();
}
if (newImage == null) {
newImage = new ArrayList<>();
} else {
newImage.clear();
}
// get the
Cursor cursor = db.query("yeni",
null,
null,
null,
null,
null,
null
);
while (cursor.moveToNext()) {
nameList.add(cursor.getString(cursor.getColumnIndex("name")));
name2List.add(cursor.getString(cursor.getColumnIndex("name2")));
name3List.add(cursor.getString(cursor.getColumnIndex("name3")));
byte[] b = cursor.getBlob(cursor.getColumnIndex("image"));
Bitmap bmp = BitmapFactory.decodeByteArray(b,0,b.length);
newImage.add(bmp);
}
cursor.close();
}
}
Main2Activity
删除 2 行:-
Intent intent = new Intent(getApplicationContext(), MainActivity.class); //kaydet'e bastığında anasayfaya yönlendirilsin
startActivity(intent);
this.finish(); //<<<< ADD this to finish Main2Activity and return to MainActivity
关于java - 尝试使用 SqliteDatabase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50671821/
我正在编写一个具有以下签名的 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
我是一名优秀的程序员,十分优秀!