[Solved] What Grammar to use when recognizing letters

You are currently loading two grammers into your recognizer. I believe digits.gram contains numbers. File menuGrammar = new File(modelsDir, “grammar/menu.gram”); recognizer.addGrammarSearch(MENU_SEARCH, menuGrammar); File digitsGrammar = new File(modelsDir, “grammar/digits.gram”); So I think what you could do is make a file letter.gram and load it into your program #JSGF V1.0; grammar speech; public <speech> = A | … Read more

[Solved] Error on line 35 in a 32 line program

You have a red exclamaition mark on your project. Eclipse is likly to not build your project if build path problems (e.g.) aren’t resolved. So go to the Problems tab and try to resolve your errors there. If that is finished Eclipse will build your project and gives more helpful errors Edit and that is … Read more

[Solved] How to print 10 numbers per line in java

while loops? Why not use for loops? They are much better in this kind of situation i.e. when you want to repeat something a known number of times. You can use a nested for loop to make this happen: int counter = 0; for (int i = 0 ; i < 10 ; i++) { … Read more

[Solved] Separate Int from String on file input [closed]

Depending on your needs, it looks like something that could be solved using regex or string splitting by a regex number pattern then filtering out what you need. Example of doing the first line for matching 1 and 3 String s = “Z=1X1+3X2”; Pattern p = Pattern.compile(“([13])”); Matcher m = p.matcher(s); while (m.find()) { System.out.println(m.group()); … Read more

[Solved] convert String to Util date in “dd-MMM-yyyy” fromat [duplicate]

Conversion To convert a String into a java.util.Date of a specific format, you can use a java.text.DateFormat. DateFormat objects can perform conversions in both directions, from String to Date by calling format() and from Date to String by calling parse(). DateFormat objects can be obtained in multiple ways, here are some: Obtain an instance via … Read more

[Solved] Creating custom java exception [duplicate]

This should help you for scanning Integer values. try{ System.out.print(“Enter an integer: “); int number = input.nextInt(); } catch (InputMismatchException ex) { System.out.println(“Incorrect input: an integer is required)”); //It’s also possible to throw your custom Exception here, like “throw new CustomException();” } About the IndexOutOfBoundsException, just write a try catch block around the area, where … Read more

[Solved] What does the statement Object[][] data = new Object [][] mean?

In this statement Object[][] data = new Object[sheet.getLastRowNum()][sheet.getRow(0).getLastCellNum()]; It is creating an array of references to arrays of references to Objects. The first array is for rows and the leaf arrays are for column values. In reality, only String objects are added so I would write it like this. int rows = sheet.getLastRowNum(); int columns … Read more

[Solved] Object ob; and Object ob = new Object; [closed]

First is declared object: Object ob; Note that declarations do not instantiate objects. When object is declared, its value is initially set to null. Second is declared and instantiated object: Object ob = new Object(); In this case you are initialize new object of type Object over constructor methods. Quick info you can get here. … Read more

[Solved] Is a given date older than a week? [closed]

Coming from the same country, I think I understand why she posted this question. The reason is quite complicated and and you may not understand unless you have a working understanding of the culture. Anyway, saying the following code is a better way would suffice. System.currentTimeMillis() – date.getTime() > 7 * 24 * 60 * … Read more

[Solved] How to connect two classes of two different packages?

You could import the packages by putting this above your class declaration import packageA.Mypoint; or import packageB.MyCircle; Also, since a circle is made up of points, you could use inheritance, so all Mypoint methods will be available to objects created from the Mycircle class public class Mycircle extends Mypoint 1 solved How to connect two … Read more