[Solved] convert uppercase letter to lowercase letter

Code of Uppercase alphabet ‘A’ is 67 and Code of Lowercase alphabet is ‘a’ is 97. So, the offset is 32. So, to convert any Uppercase alphabet to Lowercase alphabet you have to add 32 i.e. offset to it. Edit: public class CaseConverter{ public static void main(String args[]){ int offset=”a” – ‘A’; int temp = … Read more

[Solved] Add new Button to LinearLayout at Runtime in Android

considering you are a newbie: Button myButton = new Button(context); LinearLayout.LayoutParams lparms = new LinearLayout.LayoutParams(0,LayoutParams.FILL_PARENT); lparms.weight = 1; lparms.gravity = Gravity.CENTER; myButton.setLayoutParams(lparms); myButton.setBackground(getResources().getDrawable(R.drawable.android_btn_md)); myButton.setOnClickListener(btnMMClick); myButton.setText(“M-“); myButton.setTextColor(Color.parseColor(“#000000”)); myButton.setTextSize(25); myButton.setTypeface(null, Typeface.BOLD); 1 solved Add new Button to LinearLayout at Runtime in Android

[Solved] Search Student in File

You are reading lines from the file and assigning its content to str, but you never do something with this value. Also, Student seems to be empty. Supposing your file includes only the ID of the student: BufferedReader read = new BufferedReader(new FileReader(file)); String str; while((str=read.readLine())!=null) { // Your constructor assigns str to ID property … Read more

[Solved] Using Brute Force to generate all possible combination of binary numbers as array? [closed]

First of all, you need to provide a minimal reproducible example of your code. You can check here: https://stackoverflow.com/help/minimal-reproducible-example In regards to your question, using three loops can be a solution: import java.util.ArrayList; public class Main { public static void main(String[] args) { var combinations = new ArrayList<int[]>(); for (int i = 0; i < … Read more

[Solved] What’s wrong with my java code

Well it could be many things, If you’re a beginner in Java I’d reccomend starting with an IDE, howver if you dont want this then here is a link on 3 ways to resolve NoClassDefFoundError in Java Here is also an extract from another user who explains why this error occurs: I always get that … Read more

[Solved] How to Force Java to Print out Large Numbers without the use of Long or Double? [duplicate]

I tried using the long type, but unfortunately, that didn’t work long finalP = startingP * growthR; As long as startingP and growthR are still int, this calculation will still be done using 32 bit integers (and only converted to 64 bit integers afterwards, when you already encountered overflow). You can change all your variables … Read more

[Solved] Java: Objects in parameters [closed]

Well the reason should be comprehended easily. It is just a simple way to pass information inside that method. In this manner, you are creating a method variable, who has a reference to the object being passed as an argument when the method is called. And you can use this information inside the method (i.e: … Read more

[Solved] Unexpected type Average

You meant: sum = sum + one; // or sum += one; By command prompt, I think you actually mean the compiler (which can write its error messages to the command prompt). The error message will be stating that the result of (sum + one) is not a variable. See section 15.26. Assignment Operators of … Read more

[Solved] Reading Characters from StdIn [closed]

Try the Scanner class. Like this: import java.util.Scanner; public class New { public static void main(String[] args) { System.out.println(“Calculator”); Scanner scanner = new Scanner(System.in); System.out.println(“Enter Parameter “); System.out.print(“a : “); float a = scanner.nextFloat(); System.out.print(“+|-|*|/: “); String op = scanner.next(); System.out.print(“b : “); float b = scanner.nextFloat(); float c = 0; switch (op) { case … Read more

[Solved] java converting date in string format to timestamp

String str = “Fri Mar 1, 2013 4:30 PM”; SimpleDateFormat sdf1 = new SimpleDateFormat(“EEE MMM dd, yyyy hh:mm a”); Date date = sdf1.parse(str); System.out.println(“Date Object:” + date); SimpleDateFormat sdf2 = new SimpleDateFormat(“yyyy-MM-dd HH:mm a”); System.out.println(“Formatted Date:” + sdf2.format(date)); Output: Date Object: Fri Mar 01 16:30:00 EST 2013 Formatted Date: 2013-03-01 16:30 PM solved java converting … Read more

[Solved] Decryption method for two keys

All I needed to do was fix my getKey method. The changes below are what I did: public int getKey(String s){ int [] arr=countLetters(s); int maxDex=indexOfMax(arr); int key; if (maxDex<4) key= maxDex-4+26; else key=maxDex-4; return key; } solved Decryption method for two keys

[Solved] Can I parse my JSON data like this?

As you create an empty map, if you attempt to read “createdDate” you will get null as a result. This won’t throw any exception. However, in the next line you want to initialize a new Date object and pass dob1 (which is still always null). This will cause an IllegalArgumentException to be thrown. You could … Read more