parseint

v-model实现简易计算器

穿精又带淫゛_ 提交于 2019-12-15 20:10:51
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script src="./lib/vue-2.4.0.js"></script> </head> <body> <div id="app"> <input type="text" v-model="n1"> <select v-model="opt"> <option value="+">+</option> <option value="-">-</option> <option value="*">*</option> <option value="/">/</option> </select> <input type="text" v-model="n2"> <input type="button" value="=" @click="calc"> <input type="text" v-model="result"> </div> <script> /

NumberFormatException when attempting to parse string as an integer

我是研究僧i 提交于 2019-12-13 22:30:44
问题 Exception in thread "main" java.lang.NumberFormatException: For input string: " 400" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:470) at java.lang.Integer.parseInt(Integer.java:514) at Library.loadBooks(Library.java:191) at UseLibrary.main(UseLibrary.java:102) what's the problem? 回答1: You have a whitespace in " 400" that is resulting in a NumberFormatException . Just use String.trim() before trying to parse. Read

Javascript Date issue, incorrect timezone

我怕爱的太早我们不能终老 提交于 2019-12-13 18:46:28
问题 I got this strange JavaScript bug that I can seem to work arround or fix. I am using some code to make 2 JavaScript dates, to insert events into a calendar component. The dates are built the following way: var endDate = new Date(); var startDate = new Date(); startDate.setDate(startDateDay); startDate.setMonth(startDateMonth); startDate.setFullYear(startDateYear); startDate.setHours(2, 0, 0, 0); endDate.setDate(endDateDay); endDate.setMonth(endDateMonth); endDate.setFullYear(endDateYear);

What is the best way to extract this int from a string in Java?

 ̄綄美尐妖づ 提交于 2019-12-13 15:35:07
问题 Here are examples of some input that I may be given 1,4 34,2 -99,20 etc. Therefore negative values are included and 1, 2, 3, etc digits are possible. Commas are not the only delimiters, just an example. But Non integer values are the reason parseInt won't work. What can I code that will allow me to parse the above 3 inputs so that I get this? 1 34 -99 回答1: Use this code: String str = "1,4 34,2 -99,20"; String[] arr = str.split("\\D+(?<![+-])"); for (int i=0; i<arr.length; i+=2) System.out

NumberFormatException with Integer.parseInt() [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-13 07:46:59
问题 This question already has answers here : What is a NumberFormatException and how can I fix it? [duplicate] (9 answers) Closed 3 years ago . I've a problem with Integer.parseInt(). Specifically my code do this: serverPort variable is an int correctly initialized to 1910 byte[] multicastMessage = (serverAddress+"::"+String.valueOf(serverPort)).getBytes(); byte[] receivedBytes = receivePacket.getData(); receivedString = new String(receivedBytes, "UTF-8"); String[] decodedString = receivedString

Comparing 2 times with jquery

纵饮孤独 提交于 2019-12-13 07:43:40
问题 Thanks in advance for any help... I'm trying to (1) generate a begin time and end time for a form, (2) find the difference between the two, and (3) add the difference to a new input. Here's what I have so far: <a href="#" id="starttime">Begin time</a> <input id="starttimeinput" name="starttimeinput" type="text" value=""> <script> $("#starttime").click(function () { var begintime = event.timeStamp; $("#starttimeinput").val(begintime); }); </script> <a href="#" id="endtime">end time</a> <input

Barcode Numbers too long for Integer.parseInt

懵懂的女人 提交于 2019-12-12 06:38:48
问题 im using zbar for barcode services, and at certain numbers the app shutsdown. Im scanning barcodes, receive the barcode in an edittext, have it set up so it would search the json array for matching id's. Well this works fine for normal numbers the way that Integers extend to.. However i have a need to have it accept what ever value it contains. Also when using breakpoints like 000.000.000.0 and 22-22ON the app shuts down. Does anyone have a clue on how to avoid this? Is it possible to have it

Java thinks I want to convert char to String using Integer.parseInt()

柔情痞子 提交于 2019-12-12 06:20:17
问题 I get the error message error: incompatible types: char cannot be converted to String return Integer.parseInt(cases2[0]); but my code is: public static int standingOvation(String cases){ char[] cases2 = cases.toCharArray(); return Integer.parseInt(cases2[0]); } Why am I getting the error if i'm clearly trying to convert cases (which is passed in as "11111" ) to an integer? 回答1: Try return Integer.parseInt("" + cases2[0]); By adding to the empty string "" you convert to a string, which is the

How can I determine which element is causing an overflow?

筅森魡賤 提交于 2019-12-12 04:57:15
问题 I've got this code: String testData = File.ReadAllText("siteQueryTest.txt"); XDocument xmlDoc = XDocument.Parse(testData); List<SiteQuery> sitequeries = (from sitequery in xmlDoc.Descendants("SiteQuery") select new SiteQuery { Id = Convert.ToInt32(sitequery.Element("Id").Value), UPCPackSize = Convert.ToInt32(sitequery.Element("UPCPackSize").Value), UPC_Code = sitequery.Element("UPC_Code").Value, crvId = sitequery.Element("crvId").Value, dept = Convert.ToInt32(sitequery.Element("dept").Value),

Assign split string to parsed int

徘徊边缘 提交于 2019-12-11 23:51:53
问题 i'm getting this error and i can't quite figure out how to fix it. error: incompatible types found : int required: int[] array[x] = Integer.parseInt(elements[0]); here is the code for my method. The file being used is a text file of 1000 numbers, 2 per line with 500 lines, separated by commas. Example: 1,2 16,92 109,7 the purpose of this block is to read all lines of the text file, and assign all numbers to the 2d integer array. public static int[][] writeTypes(){ String position; String[]