24.Android中的列表--ListView

ListView

1.简单列表--ArrayAdapter

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:orientation="vertical"
        android:paddingLeft="10dp">
        <Button
            android:id="@+id/btn_array_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="Array列表"/>
        <Button
            android:id="@+id/btn_array_simple"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="Simple列表"/>
    </LinearLayout>

</ScrollView>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".ArrayListActivity">
    <ListView
        android:id="@+id/lv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>

package com.example.listviewtest;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button btn_array_list = findViewById(R.id.btn_array_list);
        btn_array_list.setOnClickListener(this);

        Button btn_array_simple = findViewById(R.id.btn_array_simple);
        btn_array_simple.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.btn_array_list){
            Intent intent = new Intent(this, ArrayListActivity.class);
            startActivity(intent);
        } else if (view.getId() == R.id.btn_array_simple) {
            Intent intent = new Intent(this, SimpleListActivity.class);
            startActivity(intent);
        }
    }
}

package com.example.listviewtest;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

public class ArrayListActivity extends AppCompatActivity {
    private ListView mListView;
    private List<String> mStringList;
    private ArrayAdapter<String> mArrayAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_array_list);

        mListView = findViewById(R.id.lv);

        mStringList = new ArrayList<>();

        for (int i = 0; i < 50; i++) {
            mStringList.add("这是条目"+i);
        }

        mArrayAdapter = new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,mStringList);

        mListView.setAdapter(mArrayAdapter);
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Toast.makeText(ArrayListActivity.this,"你点击了"+i,Toast.LENGTH_LONG).show();
            }
        });
    }
}

2.图文列表--SimpleAdapter

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".SimpleListActivity">
    <ListView
        android:id="@+id/lv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>

<?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"
    android:paddingLeft="10dp"
    android:paddingTop="5dp"
    android:paddingRight="10dp"
    android:paddingBottom="5dp">
    <ImageView
        android:id="@+id/iv_img"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:scaleType="centerCrop"
        android:src="@drawable/ic_launcher_background"/>
    <TextView
        android:id="@+id/tv_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_toRightOf="@id/iv_img"
        android:ellipsize="end"
        android:maxLines="1"
        android:textSize="20sp"
        android:textStyle="bold"
        android:text="雨中漫步"/>
    <TextView
        android:id="@+id/tv_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/tv_title"
        android:layout_marginLeft="10dp"
        android:layout_toRightOf="@id/iv_img"
        android:ellipsize="end"
        android:maxLines="3"
        android:text="人生就像时一场旅行,不必在乎目的地,在乎你妈说的你妈的嘛嘛嘛才是能真的嘛嘛嘛对咯收到反馈大姐夫,啊塞德里克复健科老师的会计法 阿是两地分居"
        android:textSize="16sp"/>

</RelativeLayout>

package com.example.listviewtest;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SimpleListActivity extends AppCompatActivity {
    private ListView mListView;
    private SimpleAdapter mSimpleAdapter;
    private List<Map<String,Object>> mList;
    private int[] imgs = {
            R.drawable.test1,
            R.drawable.test2,
            R.drawable.test3,
            R.drawable.test4,
            R.drawable.test5,
            R.drawable.test6,
            R.drawable.test7,
            R.drawable.test8,
            R.drawable.test9,
            R.drawable.test10
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_simple_list);

        mListView = findViewById(R.id.lv);
        mList = new ArrayList<>();
        for (int i = 0; i < 50; i++) {
            Map<String,Object> map = new HashMap<>();
            map.put("img",imgs[i%imgs.length]);
            map.put("title","这是标题"+i);
            map.put("content","这是内容"+i);

            mList.add(map);
        }
        mSimpleAdapter = new SimpleAdapter(this,mList,
                R.layout.list_item_layout,
                new String[]{"img","title","content"},
                new int[]{R.id.iv_img,R.id.tv_title,R.id.tv_content});
        mListView.setAdapter(mSimpleAdapter);
    }
}

3.图文复杂列表--BaseAdapter

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:orientation="vertical"
        android:paddingLeft="10dp">
        <Button
            android:id="@+id/btn_array_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="Array列表"/>
        <Button
            android:id="@+id/btn_array_simple"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="Simple列表"/>
        <Button
            android:id="@+id/btn_array_base"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="BaseAdapter列表"/>
    </LinearLayout>

</ScrollView>

package com.example.listviewtest;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button btn_array_list = findViewById(R.id.btn_array_list);
        btn_array_list.setOnClickListener(this);

        Button btn_array_simple = findViewById(R.id.btn_array_simple);
        btn_array_simple.setOnClickListener(this);

        Button btn_array_base = findViewById(R.id.btn_array_base);
        btn_array_base.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.btn_array_list){
            Intent intent = new Intent(this, ArrayListActivity.class);
            startActivity(intent);
        } else if (view.getId() == R.id.btn_array_simple) {
            Intent intent = new Intent(this, SimpleListActivity.class);
            startActivity(intent);
        } else if (view.getId() == R.id.btn_array_base) {
            Intent intent = new Intent(this, BaseAdapterActivity.class);
            startActivity(intent);
        }
    }
}

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".BaseAdapterActivity"
    android:orientation="vertical">
    <ListView
        android:id="@+id/lv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>

package com.example.listviewtest;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import com.example.listviewtest.adapter.MyAdapter;
import com.example.listviewtest.bean.ItemBean;

import java.util.ArrayList;
import java.util.List;

public class BaseAdapterActivity extends AppCompatActivity {
    private ListView mListView;
    private List<ItemBean> mBeanList;
    private MyAdapter mMyAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_base_adapter);

        initView();
        initData();
        initEvent();
    }

    private void initEvent() {
        mMyAdapter = new MyAdapter(this,mBeanList);
        mListView.setAdapter(mMyAdapter);
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                ItemBean itemBean = mBeanList.get(i);
                String title = itemBean.getTitle();
                Toast.makeText(BaseAdapterActivity.this,"您点击了"+i+title,Toast.LENGTH_LONG).show();
            }
        });
        mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
                return false;
            }
        });
    }

    private void initData() {
        mBeanList = new ArrayList<>();

        ItemBean itemBean1 = new ItemBean();
        itemBean1.setTitle("我的小黑狗");
        itemBean1.setContent("我的小黑狗,明天就到了,到底是死是活,没人知道,希望你不会挂");
        itemBean1.setImgResId(R.drawable.test1);

        ItemBean itemBean2 = new ItemBean();
        itemBean2.setTitle("我的小白狗");
        itemBean2.setContent("我的小白狗,以前跑丢了,希望你不会被狗贩子抓去杀了,卖狗肉");
        itemBean2.setImgResId(R.drawable.test2);

        ItemBean itemBean3 = new ItemBean();
        itemBean3.setTitle("我的小黑狗");
        itemBean3.setContent("我的小黑狗,明天就到了,到底是死是活,没人知道,希望你不会挂");
        itemBean3.setImgResId(R.drawable.test3);

        ItemBean itemBean4 = new ItemBean();
        itemBean4.setTitle("我的小白狗");
        itemBean4.setContent("我的小白狗,以前跑丢了,希望你不会被狗贩子抓去杀了,卖狗肉");
        itemBean4.setImgResId(R.drawable.test4);

        ItemBean itemBean5 = new ItemBean();
        itemBean5.setTitle("我的小黑狗");
        itemBean5.setContent("我的小黑狗,明天就到了,到底是死是活,没人知道,希望你不会挂");
        itemBean5.setImgResId(R.drawable.test5);

        ItemBean itemBean6 = new ItemBean();
        itemBean6.setTitle("我的小白狗");
        itemBean6.setContent("我的小白狗,以前跑丢了,希望你不会被狗贩子抓去杀了,卖狗肉");
        itemBean6.setImgResId(R.drawable.test6);

        ItemBean itemBean7 = new ItemBean();
        itemBean7.setTitle("我的小黑狗");
        itemBean7.setContent("我的小黑狗,明天就到了,到底是死是活,没人知道,希望你不会挂");
        itemBean7.setImgResId(R.drawable.test7);

        ItemBean itemBean8 = new ItemBean();
        itemBean8.setTitle("我的小白狗");
        itemBean8.setContent("我的小白狗,以前跑丢了,希望你不会被狗贩子抓去杀了,卖狗肉");
        itemBean8.setImgResId(R.drawable.test8);

        ItemBean itemBean9 = new ItemBean();
        itemBean9.setTitle("我的小黑狗");
        itemBean9.setContent("我的小黑狗,明天就到了,到底是死是活,没人知道,希望你不会挂");
        itemBean9.setImgResId(R.drawable.test9);

        ItemBean itemBean10 = new ItemBean();
        itemBean10.setTitle("我的小白狗");
        itemBean10.setContent("我的小白狗,以前跑丢了,希望你不会被狗贩子抓去杀了,卖狗肉");
        itemBean10.setImgResId(R.drawable.test10);

        mBeanList.add(itemBean1);
        mBeanList.add(itemBean2);
        mBeanList.add(itemBean3);
        mBeanList.add(itemBean4);
        mBeanList.add(itemBean5);
        mBeanList.add(itemBean6);
        mBeanList.add(itemBean7);
        mBeanList.add(itemBean8);
        mBeanList.add(itemBean9);
        mBeanList.add(itemBean10);

    }

    private void initView() {
        mListView = findViewById(R.id.lv);
    }
}

package com.example.listviewtest.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.listviewtest.R;
import com.example.listviewtest.bean.ItemBean;

import java.util.List;

public class MyAdapter extends BaseAdapter {
    private List<ItemBean> mBeanList;
    private LayoutInflater mLayoutInflater;
    private Context mContext;
    public MyAdapter(Context context, List<ItemBean> beanList){
        this.mContext = context;
        this.mBeanList = beanList;
        mLayoutInflater = LayoutInflater.from(mContext);
    }
    @Override
    public int getCount() {
        return mBeanList.size();
    }

    @Override
    public Object getItem(int i) {
        return mBeanList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = mLayoutInflater.inflate(R.layout.list_item_layout,viewGroup,false);

        ImageView imageView = view.findViewById(R.id.iv_img);
        TextView tvTitle= view.findViewById(R.id.tv_title);
        TextView tvContent = view.findViewById(R.id.tv_content);

        ItemBean itemBean = mBeanList.get(i);

        imageView.setImageResource(itemBean.getImgResId());
        tvTitle.setText(itemBean.getTitle());
        tvContent.setText(itemBean.getContent());

        return view;

    }
}

package com.example.listviewtest.bean;

public class ItemBean {
    private String title;
    private String content;
    private int imgResId;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getImgResId() {
        return imgResId;
    }

    public void setImgResId(int imgResId) {
        this.imgResId = imgResId;
    }

    @Override
    public String toString() {
        return "itemBean{" +
                "title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", imgResId=" + imgResId +
                '}';
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/371133.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

大数据分析|大数据分析的十大应用领域

有许多技术可用于分析大数据。这项工作介绍了BDA适用的各种分析技术领域如下。 &#xff08;1&#xff09;社会分析 社交分析是实时数据分析中一个重要且不断发展的分析方法。它分为社交网络(例如&#xff0c;Facebook和LinkedIn)&#xff0c;博客(例如&#xff0c;Blogger和W…

ERP 系统架构的设计与实践总结

企业资源计划&#xff08;ERP&#xff09;系统是一种集成多个业务功能的综合性软件解决方案。在设计和实践 ERP 系统架构时&#xff0c;需要考虑诸多因素&#xff0c;以确保系统能够满足企业的需求&#xff0c;并提供高效、可靠、安全的服务。本文将介绍一些关键的设计原则和实…

101 C++内存高级话题 内存池概念,代码实现和详细分析

零 为什么要用内存池&#xff1f; 从前面的知识我们知道&#xff0c;当new 或者 malloc 的时候&#xff0c;假设您想要malloc 10个字节&#xff0c; char * pchar new char[10]; char *pchar1 malloc(10); 实际上编译器为了 记录和管理这些数据&#xff0c;做了不少事情&…

vue中 日期选择--本日、本周、本月、本年选择器实现(基于elementui)

效果图&#xff1a; 由于项目需要图标统计展示&#xff0c;需要日期美观化选择如上图所示&#xff0c;代码如下&#xff1a; <template><div class"el-page body"><el-row><el-col class"statistic-analysis-report-style" :span&qu…

【Linux进程间通信】匿名管道

【Linux进程间通信】匿名管道 目录 【Linux进程间通信】匿名管道进程间通信介绍进程间通信目的进程间通信发展进程间通信分类 管道用fork来共享管道原理站在文件描述符角度——深度理解管道站在内核角度——管道本质 匿名管道在myshell中添加管道的实现&#xff1a;管道读写规则…

【iOS ARKit】环境反射

环境反射 在使用 iOS AR中 渲染虚拟物体时&#xff0c;RealityKit 默认使用了一个简单的天空盒&#xff08;Skybox&#xff0c;即IBL环境资源贴图&#xff09;&#xff0c;所有带反射材质的物体默认会对天空盒产生反射。 但在AR 中&#xff0c;使用IBL 技术实现的天空盒反射有一…

【快速上手QT】01-QWidgetQMainWindow QT中的窗口

总所周知&#xff0c;QT是一个跨平台的C图形用户界面应用程序开发框架。它既可以开发GUI程序&#xff0c;也可用于开发非GUI程序&#xff0c;当然我们用到QT就是要做GUI的&#xff0c;所以我们快速上手QT的第一篇博文就讲QT的界面窗口。 我用的IDE是VS2019&#xff0c;使用QTc…

神经网络 | 基于 CNN 模型实现土壤湿度预测

Hi&#xff0c;大家好&#xff0c;我是半亩花海。在现代农业和环境监测中&#xff0c;了解土壤湿度的变化对于作物生长和水资源管理至关重要。通过深度学习技术&#xff0c;特别是卷积神经网络&#xff0c;我们可以利用过去的土壤湿度数据来预测未来的湿度趋势。本文将使用 Pad…

Postgresql体系结构

client连接PostgreSQL过程&#xff1a; 1、客户端发起请求 2、主服务postmaster进程负责服务器是否接受客户端的host通信认证&#xff0c;服务器对客户端进行身份鉴别 3、主服务进程为该客户端单独fork一个客户端工作进程postgres 4、客户端与postgres进程建立通信连接&#xf…

【算法与数据结构】647、516、LeetCode回文子串+最长回文子序列

文章目录 一、647、回文子串二、516、最长回文子序列三、完整代码 所有的LeetCode题解索引&#xff0c;可以看这篇文章——【算法和数据结构】LeetCode题解。 一、647、回文子串 思路分析&#xff1a;判断一个字符串是否为回文串那么必须确定回文串的所在区间&#xff0c;而一维…

SQL--DDL

全称 Structured Query Language&#xff0c;结构化查询语言。操作关系型数据库的编程语言&#xff0c;定义了 一套操作关系型数据库统一标准。 1 SQL通用语法 在学习具体的SQL语句之前&#xff0c;先来了解一下SQL语言的同于语法。 1). SQL语句可以单行或多行书写&#xff0…

处理SERVLET中的错误和异常

处理SERVLET中的错误和异常 应用服务器服务客户机请求时可能会遇到一些问题,如找不到所请求的资源或运行中的servlet引发异常。例如,在线购物门户中如果用户选择了当前缺货的物品要放入购物车中,就会出现问题, 这种情况下,浏览器窗口中将显示错误消息。您可以在servlet中…

Maven工程的配置及使用

一、Maven章节 Maven 是 Apache 软件基金会组织维护的一款专门为 Java 项目提供构建和依赖管理支持的工具 1.1、maven的作用 1&#xff09;依赖管理&#xff1a; 方便快捷的管理项目依赖的资源包&#xff08;jar包&#xff09;避免版本冲突 2&#xff09;统一项目结构&…

STC系列单片机的中断系统

目录 一、中断系统的定义 二、STC15系列单片机的中断请求源及结构图 三、中断查询表以及触发方式 四、在keil c中如何声明中断函数 五、外部中断 六、基于STC15芯片实战中断系统的使用 &#xff08;1&#xff09;外部中断2/外部中断3来检测门的开关状态 &#xff08;2&a…

【C++】- 继承(继承定义!!基本格式!切片概念!!菱形继承详解!)

继承 了解继承继承的定义基类和派生类对象赋值转换继承中的作用域派生类的默认成员函数继承和友元菱形继承和菱形虚拟继承 了解继承 继承机制是面向对象程序设计使代码可以复用的最重要的手段&#xff0c;它允许程序员在保 持原有类特性的基础上进行扩展&#xff0c;增加功能&a…

优化 IT 支出和消除浪费的 8 种主要方法

不懈追求最佳 IT 支出对于任何组织的长期可持续发展和成功都至关重要。在这个技术快速进步的时代&#xff0c;您必须做出明智的决策&#xff0c;消除浪费&#xff0c;同时最大限度地提高技术投资的价值。 从进行 IT 成本分析到采用敏捷预算和技术标准化&#xff0c;这些策略对…

关于服务器解析A记录和CNAME记录的分析

内容提要: 大致讲下理解,dns域名解析这一块 0 . 问题来源 最近搞了一个七牛云上传,然后需要配置融合cdn加速,也就是可以加速域名,中间有一部需要CNAME 域名,也就是将七牛云提供的域名CNAME一下,查阅资料其实就是起一个别名,好访问而已. 方便我们访问云存储,达到加速的效果. …

Elasticsearch(ES) 简述请求操作索引下文档 增删查改操作

上文 Elasticsearch(ES) 创建带有分词器规则的索引 带着大家创建了一个带有分词功能的索引 老规矩 我们启动一下ES服务 本文 我们就来说说 关于文档的操作 我们先来添加一个文档 就像数据库加一条数据一样 这里 并不需要指定什么表结构和数据结构 它的文档结构是无模式的 添…

es6中标签模板

之所以写这篇文章&#xff0c;是因为标签模板是一个很容易让人忽略的知识点 首先我们已经非常熟悉模板字符串的使用方法 const name "诸葛亮" const templateString hello, My name is ${name}标签模板介绍 这里的标签模板其实不是模板&#xff0c;而是函数调用…

2024年Java面试题大全 面试题附答案详解,BTA内部面试题

基础篇 1、 Java语言有哪些特点 1、简单易学、有丰富的类库 2、面向对象&#xff08;Java最重要的特性&#xff0c;让程序耦合度更低&#xff0c;内聚性更高&#xff09; 阿里内部资料 基本类型 大小&#xff08;字节&#xff09; 默认值 封装类 6、Java自动装箱与拆箱 装箱就是…