Append a string into a string
just use ‘.=’ operator Example
1 2 3 |
foreach ($fieldValueMap as $field => $value) { $where.='`'.$field.'`="'.$value.'",'; } |
Programmers Reference Site
just use ‘.=’ operator Example
1 2 3 |
foreach ($fieldValueMap as $field => $value) { $where.='`'.$field.'`="'.$value.'",'; } |
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Possible issues: 1. Database name is not set when creating connection to MYSQL database.
According to dictionary provide by Google(R), polymorphism is the occurrence of different forms among the members of a population or colony, or in the life cycle of an individual organism. In java programming according to Oracle(R) docs, a Subclasses of a class can define their own unique behaviors and yet share some of the same …
Immutable is a type of class that once created, its content can’t be change. To make your class Immutable, you have to: Declare your Class as final. This is to prevent other class from extending. See Image#1 Properties must be declared as final. This is to prevent from setting their values after instantiation. See Image#2 …
According to Oracle(R) docs, Inheritance. A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class). The simplest example of this is the Student is a Person. In this example the Student class simply copies …
In programming, Factory Pattern can be describe as object builder and one of the best example for this is Vehicle Factory were we will build a vehicle according to ordered type. example: Step 1: Create your abstract Vehicle class and define its properties. You can also use Interface.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
abstract class Vehicle { protected double price; protected String vehicleType = "BICYCLE"; public double getPrice() { return this.price; } public String getName() { return this.vehicleType; } } |
Step 2: Create Car vehicle class …
Sorting the items in the list is as simple as below example.
1 2 |
Collection.sort(List<E>); Collection.reverse(List<E>); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
package javautillistdemo; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * * @author programmingstacks.com */ public class SortingListDemo { public static void main(String[] args) { List<String> strings = new ArrayList<>(); strings.add("A"); strings.add("C"); strings.add("AE"); strings.add("B"); strings.add("G"); strings.add("AE"); //sorting in revers order of the list, and not in any particular order. Collections.reverse(strings); for (int i = 0; i < strings.size(); i++) { System.out.println(strings.get(i)); } System.out.println("---"); //sorting in order in alphabet or in number value Collections.sort(strings); for (int i = 0; i < strings.size(); i++) { System.out.println(strings.get(i)); } } } |
Output: AE G B AE C A — A AE AE B C G
This is my Day3 of #100DaysOfCode Challenge. java.util.List is an Interface that accepts all Objects including non-literal types like Integer, Long, String, Character etc. For this #100daysOfCode challenge, I learned that: List store your data the same order how you add your items to the list. List also allows you to enter duplicate entries to …
Yes you heard that right, Java works on Pass-By-Reference and Pass-By-Value but there is a twist and this makes a lot of confusion. Before I start trying to prove that Java is both, lets start this by understanding these two concepts. Pass-By-Reference – the caller and callee shares the same variable. A good explanation from …
If you are not a graduate of any computer related course like me, you came to the right page. Here, I will try to help you get started in programming. First, let’s make you get acquainted with some terms that are very basic in programming so that you will have less struggle in searching for …