[Solved] how to replace some character’s of String

You can use string replace method. see below String number = +9231235410; String newNumber = number.replace(“+92″,”0”); EDIT: this one is base on your code private String modifyNumber(String num) { if (num.startsWith(“+92”)) { num = num.replaceFirst(“\\+(92)”, “0”);} return num;} Note: In java, you need to have double backslash since the \ is a unique java character. … Read more

[Solved] Phonebook program doesn’t work in Java

This should fix both your issues.. I’ve made a number of changes to the code, so it will be difficult to explain everything, but I’ve included the main points after the code. Try going through it and add a comment in case of any doubt. import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; … Read more

[Solved] Labeled Continue statement fails to compile

Your out label “annotates” this for-loop: out: for(i = 0 ; i <= 6 ; i++) { System.out.println(i); } So in order to continue with the label out, it would need to be within that for-loop. It doesn’t make sense to use it after that for-loop has ended. This will compile, for example: out: for(int … Read more

[Solved] what components do exist in any java class? [closed]

I think this is everything that every Java class has: A class name. A class access … implicitly package private, if you don’t specify one. A package … implicitly the default package, if you don’t specify one. A superclass … implicitly java.lang.Object, if you don’t specify one. A body which may be empty. A constructor … Read more

[Solved] Cannot understand the difference between static and non-static variables in Java. Can anyone help please? [duplicate]

Static properties belong to the Class whereas instance variables belong to the particular object instance. You should take a read through this: https://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html solved Cannot understand the difference between static and non-static variables in Java. Can anyone help please? [duplicate]

[Solved] Checking of String if it has this specific value [closed]

Regex is your friend : public static void main(String[] args) throws Exception { String s1 = “jdK1TESTds3TEST”; System.out.println(s1.replaceAll(“(?i)(.*)TEST$”, “$1”)); } O/P : jdK1TESTds3 The code above replaces the last TEST (if it exists). Add (?i) modifier to make it case-insenstive. 4 solved Checking of String if it has this specific value [closed]

[Solved] Passing data to another activity (Android Studio) [duplicate]

final String scanResult = result.getText(); Intent intent = new Intent(getBaseContext(), ResultPage.class); intent.putExtra(“SCAN_RESULT”, scanResult); startActivity(intent); Now you can find scanResult in ResultPage activity String s = getIntent().getStringExtra(“SCAN_RESULT”); 7 solved Passing data to another activity (Android Studio) [duplicate]

[Solved] Compiling Error- Unreachable Statement

That’s because there’s an infinite loop just before it: for(i = 0; 9 <26;i++) bigQ.put((char) (‘A’ + i)); Since 9 < 26 will always be true, the loop will execute forever. Did you mean to do this instead?: for(i = 0; i <26;i++) bigQ.put((char) (‘A’ + i)); 1 solved Compiling Error- Unreachable Statement

[Solved] Method to build a new Linked List with the odd numbered elements from a given Linked List [closed]

I’m not really a Java developer but this should work better: import java.util.*; public class ExtLinkedList<E> extends LinkedList<E> { public ExtLinkedList<E> oddItemsList () { ExtLinkedList<E> oddList = new ExtLinkedList<E>(); //Get the iterator of the current list instead of the new empty list. //Otherwise you will iterate over nothing. ListIterator<E> itr = listIterator(); for(int i = … Read more