[Solved] Why is it giving me the error “method ArrayList.add(String) is not applicable”?

Problem: ArrayList<String> means you want an array-backed list that can hold String objects. This restricts the add method to only accept strings. The mistake you are making is that you are passing other non-String objects into the add method. Bad Answer 1: The easy way out is to change it to ArrayList<Object>, but this defeats … Read more

[Solved] replace a vowel in string with its successor example snow will become snpw [closed]

You should not print str which value’s never changed. Try to print the StringBuffer’s object because it contains the replacements. System.out.println(“New STring is:”+a.toString()); Thanks to @Blip, I did not notice another problem. You added character to the StringBuffer’s object only if the input is a vowel. Here is what your if test should look like … Read more

[Solved] Is there any calendar view libs that support English as well as Hebrew(Arabic the same)

I’m not aware of any other calenderview for android that would solve your problem. But I think you can stick to material-calendarview. As you already mentioned there is a pull request that promises to fix the issue you’re facing. This pull request however has not yet been merged into the main branch of the prolificinteractive/material-calendarview … Read more

[Solved] How to have jtables values which are strings in alphabetical order using comparator and tablerowsorter? [closed]

You must create a comparator: Comparator<String> comparator = new Comparator<String>() { public int compare(String s1, String s2) { return s1.compareTo(s2); } }; With this comparator you will be able to sort your data in alphabetical order. After that create sorter and pass this comparator and model of your JTable. Then: sorter.sort(); I think after that … Read more

[Solved] Declare PrintWriter outside method [closed]

make changes in your code as follows package com.donemanuel.DSDK; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.Date; public class LogKit { PrintWriter logd ; void openLog() throws IOException{ Date ltm = new Date( ); SimpleDateFormat lt = new SimpleDateFormat (“‘[‘dd.MM hh:mm:ss a’]: ‘”); final String logtm = lt.format(ltm); logd = new PrintWriter(“res/LOGTIME_”+logtm, “UTF-8”); … Read more

[Solved] Method Overloading – Java

It will call (1) because the method resolution algorithm gives priority to methods that do not use varargs. To force it to use (2) you can pass an array or cast the first parameter to Object: myMethod(new Object[] { “name”, new MyClass() }); //or myMethod((Object) “name”, new MyClass()); 1 solved Method Overloading – Java

[Solved] Question >> print “True” or “False” if the string contains two or more characters

public class Demo { public static boolean contains(String str,char c){ //todo:check str for NullPointExecption int flag=0; for(int i=0;i<str.length();i++){ if(c==str.charAt(i)){ flag++; //if str contains char c,flag=flag+1 } if(flag>=2){ return true; //if flag>=2,return true } } return false; } public static void main(String[] args) { System.out.println(contains(“appple”, ‘p’));//result is true } } 7 solved Question >> print “True” … Read more

[Solved] For loop misunderstanding in java

A for loop is a control statement, but you still need some operations for that statement to exercise. The format is for (some expression controlling the number of times to do something) { some commands to run. } Currently your for loop lacks the block of commands to run In addition, the format of the … Read more

[Solved] java.lang.NumberFormatException: Invalid int: “24 pm” [closed]

You can do the following : if (time != null && !time.equals(“”)) { StringTokenizer st = new StringTokenizer(time, “:”); String timeHour = st.nextToken(); String timeMinute = st.nextToken(); timePickDialog = new TimePickerDialog(v.getContext(), new TimePickHandler(), Integer.parseInt(timeHour), Integer.parseInt(timeMinute.replace(” am”,””).replace(” pm”,””)), true); } to replace both ” am” and ” pm” with “”. 5 solved java.lang.NumberFormatException: Invalid int: “24 … Read more

[Solved] No response from jsonArray request [closed]

1. Initialize your adapter and set it to RecyclerView from onCreate() method. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Initializing Views recyclerView = (RecyclerView) findViewById(R.id.recyclerView); recyclerView.setHasFixedSize(true); layoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(layoutManager); listcollege = new ArrayList<>(); adapter = new CardAdapter(this, listcollege); recyclerView.setAdapter(adapter); getData(); } 2. Instead of JsonArrayRequest, try using JsonObjectRequest: //Creating a json object … Read more