Posts

Java array to input student names according to their number -

i need create array prompts professor input how many students in class. prompts them input names until number of students met. have wrong hoping insight. system.out.println("please enter number of students in class: "); int numberofstudents = console.nextint(); string [] studentname = new string [numberofstudents]; (int i=0; i<studentname.length; i++) { system.out.println("enter name of student " + (i+1) + " in class. "); studentname[i] = console.nextline(); system.out.println("student name entered: " + studentname[i]); } edit: changed code bit, array. loop intending have go through each number , assign student name it. last line of code gives me error saying confusing indentation. edit 2: after proofreading question , code myself i've noticed basic mistakes , have dealt them, 1 last question. right while code works, when asks me input name, skips student 1, leaves blank moves onto student...

java - Binding nested objects in SPRING MVC -

i new spring mvc. not getting details of employee contains phone , address object well. actually, object not being binded employee. follow code: //(controller) employeecontroller.java @controller @requestmapping(value = "/employee") public class employeecontroller { @autowired employeeservice employeeservice; @requestmapping("/employee") public modelandview registeremployeer(@modelattribute employee employee) { map<string, object> modelmap = new hashmap<>(); modelmap.put("employee", new employee()); return new modelandview("employee", modelmap); } @requestmapping("/add") public string addemployee(@modelattribute employee employee) { employeeservice.save(employee); return "result"; } @modelattribute("phonetypelist") public map<string,string> populatephonetypelist() { return phone.getphonetypes(); } @modelattribute("addresstypelist") public map<string,string> p...

c# - XElement XML ToString malformed [ ] -

so m parsing xml. create xelement , run tostring() method. @ results , wrong. <root>[elementname, elementvalue ]</root> when should like <root> <data name="name"> <value>value</value> </data> </root> this really weird. ive used xml plenty of times , have never run this. have looked on web , cant find anything. when step through xdocument creation process tostring() each element correct. going on ? how can troubleshoot ? here code string writexml(dictionary<string, string> dic) { var root = new xelement("root"); foreach (var pair in dic) { var element = new xelement("data", pair.value); element.add(new xattribute("name", pair.key)); root.add(pair); } var doc = new xdocument(new xdeclaration("1.0", "utf-8", null), root); var s = doc.tostring(); consol...

Android drawables : Is there any way to somehow link the int IDs to the R drawable IDs? -

i have 718 drawables in drawable-mdpi , drawable-hdpi and drawable-xhdpi folders, names 1.png, 2.png... 718.png. (they pokémon sprites) so, depending on pokémon, want load 1 of them show it. however, cannot use number directly identify r drawable id. is there way (besides of 718-case switch or hashmap<integer,integer> ) somehow link int ids r drawable ids? you try: string sprite = "drawable/"+number; int imageresource = getresources().getidentifier(sprite, null, getpackagename()); the drawable folder image in. number number of image want. e.g. 1.png

bash - Count specific numbers from a column from an input file linux -

i trying read file , count specific number @ specific place , show how many times appears, example: 1st field numbers, 2nd field brand name, 3rd field group belong to, 4th , 5th not important. 1:audi:2:1990:5 2:bmw:2:1987:4 3:bugatti:3:1988:19 4.buick:4:2000:12 5:dodge:2:1999:4 6:ferrari:2:2000:4 as output, want search column 3, , group 2's(by brand name) , count how many of them have. output looking should this: 1:audi:2:1990:5 2:bmw:2:1987:4 5:dodge:2:1999:4 6:ferrari:2:2000:4 4 -> showing how many lines there are. have tried taken approach can't figure out: file="cars.txt"; sort -t ":" -k3 $file #sorting 3rd field grep -c '2' cars.txt # counts 2's in file including number 2. i hope understand. , thank in advance. i not sure mean "group brand name", following output describe. awk -f':' '$3 == 2' input.txt if want line count, can pipe wc -l . awk -f':' '$3 == 2' i...

jquery - colorbox doesn't close after sumbit form -

i have issues colorbox if try submit form, colorbox remains opened on success. tried add colorbox.close(); on success, worked, if try click link again open form, form not displaying - can see close button , overlay. tried hide form , overlay after success, again - form didn't open on second click. i tried tweek js file - assign same functionality submit button close button has, of course didn't work properly. how make form close on submit - please suggest. the popup form: <div class="body" id="inline-popup"> <form action="index" method="post" id="form"> <fieldset> <label>name</label> <input type="text" id="name" name="name" /> </fieldset> <fieldset> <label>url (optional)</label> <input type="text" name="url" id="url" />...

c++ - How to obtain the changed file names from the QFileSystemWatcher `directoryChanged` event -

how can 1 obtain changed file names qfilesystemwatcher directorychanged event? you need connect slot filechanged() signal instead of directorychanged() if more interested in file names. connect(&myfilesystemwatcher, signal(filechanged(const qstring&)), slot(handlefilechanged(const qstring&))); then, can use slot argument desired. here, printing out stdout: void handlefilechanged(const qstring &path) { qdebug() << path; } please see documentation further details: void qfilesystemwatcher::filechanged(const qstring & path) [signal] this signal emitted when file @ specified path modified, renamed or removed disk. not sure how familiar qt signal/slot system, if not enough, please go through this, too: qt signals & slots