[Solved] What does null pointer exception mean in error messages? [duplicate]

Java doesn’t use pointers, but uses references. NullPointerException is a way to say that an attempt is made to send a message (invoke a method) using reference which doesn’t point to any object. It has nothing to do with pointers in the sense of C/C++. solved What does null pointer exception mean in error messages? … Read more

[Solved] I need to compare strings in an array and store/return the longest word [duplicate]

Your post isn’t javascript, but here’s basically what you want to do. It should be easy to change it over from javascript. function compareWords(words){ var longestWord = ”; for(var i = 0; i < words.length; i++){ if(words[i].length > longestWord.length){ longestWord = words[i]; } } return longestWord; } var words = [‘gunslinger’, ‘gundam’, ‘dragon’, ‘shirt’, ‘unicorn’, … Read more

[Solved] Convert string date to date object Java [duplicate]

You can try something like this: String str = “Saturday 17th March 2018”; DateFormat format = new SimpleDateFormat(“EEE dd MMM yyyy” , Locale.ENGLISH); System.out.println(format.parse(str.replaceAll(“(?<=\\d)(st|nd|rd|th)”, “”))); 1 solved Convert string date to date object Java [duplicate]

[Solved] When I try to add Strings to an Array List I get an “illegal start of type error”

To add items to a static list you can use the block static{} public class Employee { …. private static ArrayList <String> employeeID = new ArrayList <String> (); static { employeeID.add(“632584”); employeeID.add(“259415”); employeeID.add(“257412”); employeeID.add(“953647”); employeeID.add(“126497”); employeeID.add(“453256”); employeeID.add(“125689”); } … } } Or use constructor public class Employee { …. private static ArrayList <String> employeeID = … Read more

[Solved] How to format a date from yyyy-MM-dd to yyMMdd [closed]

Try this String s; DateFormat formatter; formatter = new SimpleDateFormat(“yyyy-MM-dd”); Date date1 = formatter.parse(“2013-07-17”); formatter = new SimpleDateFormat(“yyMMdd”); s = formatter.format(date1); System.out.println(s); 0 solved How to format a date from yyyy-MM-dd to yyMMdd [closed]

[Solved] How to add a mask over background image in activity? [closed]

Just add two imageview on top of each other using a relative layout <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent”> <ImageView android:scaleType=”centerCrop” android:src=”https://stackoverflow.com/questions/49275803/@drawable/settings” android:layout_width=”match_parent” android:layout_height=”match_parent” /> <ImageView android:alpha=”0.5″ android:background=”@color/colorPrimary” android:layout_width=”match_parent” android:layout_height=”match_parent” /> </RelativeLayout> solved How to add a mask over background image in activity? [closed]

[Solved] Is it Possible to Run Shell Script in Browser

You would need to use a Java Applet with heightened security privileges and a JavaScript API so that JavaScript in the page could read the form data and pass it to the applet. The client computer would need to have the Java plugin and whatever shell you were using installed, and the user would have … Read more

[Solved] Java: Highscore system [closed]

A viable method would be to create a simple API. If you supply FTP credentials with your app, chances are it will be hacked. If you create a simple HTTP API, you can assign a unique API key to every client, and if someone uses it for spam or whatever, you can just ban them … Read more

[Solved] How Can I initialize my variables from another layout?

//Change the name id in the xml file Button microsoftButton = (Button) findViewById(R.id.microsoftButton); TextView scoreTextView = (TextView) findViewById(R.id.scoreTextView); microsoftButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(),”Wrong!”, Toast.LENGTH_SHORT).show(); // This was declared above so now you can use it. You can only set it to a String not to an Integer. scoreTextView.setText(“0”); } }); … Read more

[Solved] Get count leading zeros in a string

You could play with parsing back and forward the string into a number, for example Integer.parseInt() will ignore leading zeros final String xs = “0001254200”; int i = xs.length() – String.valueOf(Integer.parseInt(xs)).length(); System.out.println(i); //Another option based on Titus comment i = xs.length() – xs.replaceAll(“^0+”, “”).length(); System.out.println(i); 0 solved Get count leading zeros in a string