#javadrive
Explore tagged Tumblr posts
ihubtalent · 2 years ago
Text
We are so proud to announce that we are Conducting a java Job Drive for 2020-2022, passed-out students. Drive On 28th Jan 2023 ��Contact: 9949877844 (Bhargavi)
Follow us on social Media Facebook: https://www.facebook.com/ihubplacements/ Instagram: https://www.instagram.com/ihubtalent Twitter: https://twitter.com/ihubtalent Youtube: https://www.youtube.com/c/iHubTalent ℹ️ More info: https://www.ihubtalent.com/
Tumblr media
0 notes
momijinn · 8 years ago
Text
AndroidでString配列よりListでStringを定義したほうが使いやすい
最近になってAndroidアプリをちょいちょい作っています
データを貯める時に今までString[]とかint[]といった配列を利用してきました
しかし、固定長であるため改めて何か追加するときは配列の長さを長めにとらなければならないといったデメリットがありました
いろいろ探していたらlist型というものがありそれが結構使いやすかったのでメモとして残しておきます
はじめてのAndroidプログラミング 改訂版
  注意ですが使い方のみの説明になります
list型とはなんぞやという人は各自調べてください
  宣言
ArrayList<型> 変数名 = new ArrayList<型>(); //example ArrayList<String> hoge = new ArrayList<String>();
  追加
変数名.add("hogehoge"); //example hoge.add("hogehoge"); //addAll使うとlist型を合体できる ArrayList<String> hoge1 = new ArrayList<String>(); hoge1.add("hogehoge1"); hoge1.add("hogehoge11"); ArrayList<String> hoge2 = new ArrayList<String>(); hoge2.add("hogehoge2"); hoge2.addAll(hoge1); //ここ
  削除
変数名.remove("ほげほげ"); //example ArrayList<String> hoge1 = new ArrayList<String>(); hoge1.add("hogehoge1"); hoge1.remove("hogehoge1"); hoge1.remove(0); //格納されている番号でも削除可能 //removeAll使うと削除したいものを全て消せる List<String> RemoveNounList = Arrays.asList("hoge", "test"); //消したい値 ArrayList<String> hoge1 = new ArrayList<String>(); hoge1.add("hoge"); hoge1.removeAll(RemoveNounList);
  注意
宣言するときにnewをつ��ないと可変長になりません
//これは可変長 ArrayList<String> hoge1 = new ArrayList<String>(); //これは固定長 List<String> RemoveNounList = Arrays.asList("hoge", "test");
  参考文献
JavaDrive, http://ift.tt/2sDn6PX
from AutumnColor.com http://ift.tt/2zcQlQW via IFTTT
0 notes